C# MyAssembly.XmlSerializers.dll 是为了什么而生成的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/934411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is MyAssembly.XmlSerializers.dll generated for?
提问by Hemant
I am working on a project which generates an assembly. I just noticed that an additional assembly *.XmlSerializers.dll is being generated. Why this file is auto generated and what it is used for?
我正在开发一个生成程序集的项目。我刚刚注意到正在生成一个额外的程序集 *.XmlSerializers.dll。为什么这个文件是自动生成的,它的用途是什么?
采纳答案by Grzenio
In .NETimplementation, the XmlSerializer generates a temporary assembly for serializing/deserializing your classes (for performance reasons). It can either be generated on the fly (but it takes time on every execution), or it can be pregenerated during compilation and saved in this assembly you are asking about.
在.NET实现中,XmlSerializer 生成用于序列化/反序列化类的临时程序集(出于性能原因)。它可以即时生成(但每次执行都需要时间),也可以在编译期间预先生成并保存在您询问的这个程序集中。
You can change this behaviour in project options (tab Compile-> Advanced Compile Options-> Generate serialization assemblies, Autoor On, respectively). The corresponding element in the project file is GenerateSerializationAssemblies, for example, <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
.
您可以更改项目选项这种行为(标签编译- >高级编译选项- >生成序列化组件,自动或在分别)。项目文件中对应的元素是GenerateSerializationAssemblies,例如<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
.
回答by Alan Christensen
I think this is the JIT (Just in time) compilation of XML serialisers for performance reasons.
我认为这是出于性能原因的 XML 序列化程序的 JIT(及时)编译。
You get the same thing with RegEx instances using the RegexOptions.Compiled option turned on.
使用启用 RegexOptions.Compiled 选项的 RegEx 实例可以获得相同的结果。
I'm no .NET CLR expert, sorry for lack of precise technical detail.
我不是 .NET CLR 专家,抱歉缺乏精确的技术细节。
回答by abhilash
*.XmlSerializers.dll
are generated using the Sgen.exe [XML Serializer Generator Tool]
*.XmlSerializers.dll
使用 Sgen.exe [XML Serializer Generator Tool] 生成
See Sgen.exe on MSDN
Typically the Sgen.exe
is used in Post Build events of Projects. See if your project has a post build event which generates the *.XmlSerializers.dll
通常Sgen.exe
用于项目的构建后事件。查看您的项目是否有生成后构建事件*.XmlSerializers.dll
回答by jontsnz
FYI. The exact steps to stop the XmlSerializers.dll from being auto-generated are:
供参考。停止自动生成 XmlSerializers.dll 的确切步骤是:
- In VS, right-click your project file and select "Properties"
- Click the "Build" tab
- Change the "Generate serialization assembly" dropdown from "Auto" to "Off"
- Rebuild and it will be gone
- 在 VS 中,右键单击您的项目文件并选择“属性”
- 单击“构建”选项卡
- 将“生成序列化程序集”下拉列表从“自动”更改为“关闭”
- 重建它就会消失
回答by Malcolm
The project only generates the project.XMLSerialisers.dll for web applications. For other applications you have to run sgen separately.
该项目仅为 Web 应用程序生成 project.XMLSerialisers.dll。对于其他应用程序,您必须单独运行 sgen。