xmlserializer

With this tip, I couldn't find any documentation, so you're on your own. That means no help/support from me or anywhere. YMMV - Your Mileage May Vary. No warranties. Enjoy.

有了这个技巧,我找不到任何文档,所以您自己一个人。 这意味着我或任何地方都不会提供帮助/支持。 YMMV-您的里程可能会有所不同。 没有保证。 请享用。

Someone asked:

有人问:

"When using the XmlSerializer from ASP.NET there are permissions issues can can be solved by granting the user account read/write permissions on the %SYSTEMROOT%\Temp folder but I would much rather have the temporary files created in a different folder"

“从ASP.NET使用XmlSerializer时,可以通过向用户帐户授予%SYSTEMROOT%\ Temp文件夹的读/写权限来解决权限问题,但我宁愿在其他文件夹中创建临时文件”

So I poked around. If you want the XmlSerializer to output it's assemblies elsewhere, here's how. Note that I used the previous tip on How To Debug into a .NET XmlSeraizlizer Generated Assembly just to prove this was working. It's not needed for this tip!

所以我四处张望。 如果您希望XmlSerializer将其程序集输出到其他位置,请按以下步骤操作。 请注意,我使用了有关如何调试到.NET XmlSeraizlizer生成的程序集的上一个技巧,只是为了证明它是有效的。 本技巧不需要!

To start, let's see where the temporary files end up usually.

首先,让我们看看临时文件通常在哪里结束。

First, I'll add this to my web.config (or whatever.exe.config if you like). This is just to visualize and confirm. It's not needed for this tip.

首先,我将其添加到我的web.config(或者您愿意的任何exe.exe.config)中。 这只是为了可视化和确认。 本技巧不是必需的。

<configuration><system.diagnostics><switches><add name="XmlSerialization.Compilation" value="1" /></switches></system.diagnostics>
</configuration>

I'll debug my application, but I'll use SysInternal's Process Monitor and set the filter to only show processes whose name contains the string "WebDev" and see what files the VS WebDev Server writes to. If you're using IIS, you would search for W3WP or ASPNET_WP.

我将调试应用程序,但将使用SysInternal的Process Monitor ,并将过滤器设置为仅显示名称包含字符串“ WebDev”的进程,并查看VS WebDev Server写入哪些文件。 如果使用的是IIS,则将搜索W3WP或ASPNET_WP。

Here I can see it writing to C:\Users\Scott\AppData\Local\Temp. The file names are auto-generated...note their names, in my case 6txrbdy.0.*. To prove these are the real generated XmlSerializers, I'll put a breakpoint on my app just before I call CreateSerializer and then drag the .cs file over from the TEMP folder into VS.NET. Note that the .PDB will get loaded when I hit F11 to step into.

在这里,我可以看到它写入C:\ Users \ Scott \ AppData \ Local \ Temp。 文件名是自动生成的...在我的情况下,请注意文件名6txrbdy.0。* 。 为了证明这些是真正生成的XmlSerializer,我将在调用CreateSerializer之前在应用程序上放置一个断点,然后将.cs文件从TEMP文件夹拖到VS.NET中。 请注意,当我按F11进入时,.PDB将被加载。

Make note of the Call Stack. See the name of the assembly and the name of the .cs file? So, we're sure now where this XmlSerializer came from; it came from C:\Users\Scott\AppData\Local\Temp. If we were running IIS, it'd have been in %SYSTEMROOT%\Temp. The point being, it's automatic and it's temporary and your process needs WRITE access to that folder.

记下调用堆栈。 看到程序集的名称和.cs文件的名称吗? 因此,我们现在确定XmlSerializer的来源; 它来自C:\ Users \ Scott \ AppData \ Local \ Temp。 如果我们正在运行IIS,它将位于%SYSTEMROOT%\ Temp中。 关键是,它是自动的,是临时的,您的过程需要对该文件夹进行WRITE访问。

Now, poking around in Reflector with the not-used-often-enough Analyze method shows that XmlSerializerFactory.CreateSerializer eventually ends up in XmlSerializerCompilerParameters.Create which looks for a Configuration Section called “xmlSerializer” and a key called TempFilesLocation.

现在,使用不常用的Analyze方法在Reflector中四处浏览,显示XmlSerializerFactory.CreateSerializer最终以XmlSerializerCompilerParameters.Create结尾,并在其中查找名为“ xmlSerializer”的配置节和名为TempFilesLocation的键。

That actually means it's looking for a section called System.Xml.Serializer and an element called xmlSerializer and an attribute called tempFilesLocation.

这实际上意味着它正在寻找一个名为System.Xml.Serializer的部分和一个名为xmlSerializer的元素以及一个名为tempFilesLocation的属性。

I'll add this to my web.config now:

我现在将其添加到我的web.config中:

<system.xml.serialization> <xmlSerializer tempFilesLocation="c:\\foo"/>
</system.xml.serialization> 

...and create a c:\\foo directory. Make sure your hosting process has write access to the directory.

...并创建ac:\\ foo目录。 确保您的托管进程对目录具有写权限。

I'll run my app again, and check out that new folder.

我将再次运行我的应用,然后签出该新文件夹。

I've got newly generated XmlSerializer temporary assemblies in there. Undocumented, yes, but it does the job. Note, stuff like this can totally go away at any minute, so don't base your whole design on things like this. It's your tush, not mine, on the line.

我在那里有新生成的XmlSerializer临时程序集。 无证件,是的,但是确实可以。 注意,这样的事情在任何时候都可能完全消失,所以不要将整个设计都基于这样的事情。 这是您的要求,而不是我的要求。

翻译自: https://www.hanselman.com/blog/changing-where-xmlserializer-outputs-temporary-assemblies

xmlserializer

xmlserializer_更改XmlSerializer输出临时程序集的位置相关推荐

  1. docker配置阿里云镜像加速并更改镜像和容器的存储位置及常见的docker bug解决方法

    配置阿里云镜像加速 使用docker容器管理服务,总结下来就三个重要概念: 镜像,容器,数据卷.在之前的博文中我们已经讲述了如何在linux服务器上安装docker,并运行docker服务了. 这篇文 ...

  2. Outlook 2010如何更改脱机缓存数据OST文件位置?

               Outlook 2010如何更改脱机缓存数据OST文件位置? 场景: 部分企业的Exchange server使用POP3的模式与客户端的Outlook进行通讯收发邮件,这样在客 ...

  3. 更改vs2010帮助文档的位置

    更改vs2010帮助文档的位置 2011-09-21 15:13:35|  分类: 默认分类 |  标签: |字号大中小 订阅 第一步:移动库文件 将原路径下帮助文档库的所有文件(1个cld-sett ...

  4. 更改WPS云文档保存位置

    更改WPS云文档保存位置 最近清理C盘的时候,发现C:\User\AppData\Local\Kingsoft中保存了WPS的云文档文件WPS Cloud Files,占的空间还比较大,于是写下这篇更 ...

  5. Sublime Text 3默认临时/缓存文件保存位置

    Sublime Text 3默认临时/缓存文件保存位置 Windows C:\Users\[用户名]\AppData\Roaming\Sublime Text 3\Local Linux \home\ ...

  6. 100个人围成一个圈从1开始报数,输入数m,报到m的人退出,继续从1开始报,报到m继续退出依次下去直到剩余的人小于m不再报数,输出剩下人的位置。

    题目:100个人围成一个圈从1开始报数,输入数m,报到m的人退出,继续从1开始报,报到m继续退出依次下去直到剩余的人小于m不再报数,输出剩下人的位置. import java.util.*;publi ...

  7. Pycharm的相关配置:改字体样式和大小、更改图片背景、更改控制台输出的字体颜色

    文章目录 Pycharm的相关配置:改字体样式和大小.更改图片背景.更改控制台输出的字体颜色 一.pycharm更改字体样式和大小 二.pycharm更改图片背景 三.pycharm更改控制台输出的字 ...

  8. 找出数组中第k大小的数,输出数所在的位置

    找出数组中第k大小的数,输出数所在的位置 /*写一段程序,找出数组中第k大小的数,输出数所在的位置.例如{2,4,3,4,7}中,第一大的数是7,位置在4. 第二大.第三大的数都是4,位置在1.3随便 ...

  9. 火狐 脱机文件位置不能更改_如何更改Firefox下载文件夹的位置

    火狐 脱机文件位置不能更改 By default, when you download something using Firefox, that download gets saved to the ...

最新文章

  1. 关于通讯作者、第一作者的那点事,你想知道的全都在这里!
  2. 法总统:英国若“无协议脱欧” 将成最大输家
  3. 观峰雨个人空间 2010 STOCK ADVICE !
  4. android 修改framework下资源文件后如何编译
  5. 编写一程序,有2个文本框,在第一个文本框中输入一个整数,当焦点从第一个文本框离开时,第二个文本框将显示这个数的绝对值(使用FocusListener)。
  6. 被惊艳到了!适用 Win、Mac、Linux,酷炫的极客界面 eDEX-UI
  7. Android界面菜单(4)—快捷菜单
  8. 报错,void AcceptAndReadAvailableTracks(const QString param, int timeout)
  9. 如何脱离tutorial使用igllib
  10. POJ NOI0105-40 数1的个数
  11. 树莓派(Linux)与镜像源
  12. matlab2c使用c++实现matlab函数系列教程-zeros函数
  13. python 遍历文件夹文件代码
  14. 算法(algorithm):#include<algorithm>
  15. NumPy学习笔记之zeros_like()函数(包含zeros函数)
  16. 【笔记】ubuntu 16.04 centos 7如何配置sudo权限
  17. 航天金税3发票导入功能开发教程(一)
  18. WiFi连接过程简要分析
  19. 串口连接BBB(三)
  20. 锁定计算机和睡眠有什么区别,电脑系统待机、睡眠和休眠的区别有哪些

热门文章

  1. AE2022 for Mac安装包+安装教程
  2. ArcGIS Pro建立三维模型(三维渲染)
  3. 如何更改SpringBoot控制台图标?只需一步!
  4. adb命令查看手机电池信息
  5. 计算机自带的加密,加密,详细教您如何用自带Bitlocker来为电脑磁盘加密
  6. iso8583 协议详解
  7. [Unity][Crowd]学习人群模拟资源分享以及相关的问题
  8. 使用Kinect制作变身钢铁侠
  9. htcm7刷linux,HTC One M7 怎么刷机?刷机图文教程 ?
  10. QT MetaImage 一款图片工具软件