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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:38:25  来源:igfitidea点击:

What is MyAssembly.XmlSerializers.dll generated for?

c#visual-studio-2008xml-serialization

提问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.dllare generated using the Sgen.exe [XML Serializer Generator Tool]

*.XmlSerializers.dll使用 Sgen.exe [XML Serializer Generator Tool] 生成

See Sgen.exe on MSDN

请参阅MSDN 上的 Sgen.exe

Typically the Sgen.exeis 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 的确切步骤是:

  1. In VS, right-click your project file and select "Properties"
  2. Click the "Build" tab
  3. Change the "Generate serialization assembly" dropdown from "Auto" to "Off"
  4. Rebuild and it will be gone
  1. 在 VS 中,右键单击您的项目文件并选择“属性”
  2. 单击“构建”选项卡
  3. 将“生成序列化程序集”下拉列表从“自动”更改为“关闭”
  4. 重建它就会消失

回答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。