What is MyAssembly.XmlSerializers.dll generated for?

你离开我真会死。 提交于 2019-12-27 19:51:50

问题


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?


回答1:


In .NET implementation, 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.

You can change this behaviour in project options (tab Compile -> Advanced Compile Options -> Generate serialization assemblies, Auto or On, respectively). The corresponding element in the project file is GenerateSerializationAssemblies, for example, <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>.




回答2:


FYI. The exact steps to stop the XmlSerializers.dll from being auto-generated are:

  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



回答3:


I think this is the JIT (Just in time) compilation of XML serialisers for performance reasons.

You get the same thing with RegEx instances using the RegexOptions.Compiled option turned on.

I'm no .NET CLR expert, sorry for lack of precise technical detail.




回答4:


*.XmlSerializers.dll are generated using the 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




回答5:


The project only generates the project.XMLSerialisers.dll for web applications. For other applications you have to run sgen separately.



来源:https://stackoverflow.com/questions/934411/what-is-myassembly-xmlserializers-dll-generated-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!