要清楚,我不能只使用sgen.exe,因为它只生成执行默认xml序列化/反序列化的程序集.如果你创建一个XmlSerializer和pass it XmlAttributeOverrides in the constructor然后Serialize()和Deserialize()不使用sgen.exe生成的程序集,因此sgen.exe似乎对我没用.使用覆盖时,XmlSerializer将始终生成新的程序集.
那么,有没有办法可以调用XmlSerializer或其他类并让它创建一个.cs文件或dll,我可以包含在我的项目中?如果可能的话,我想自动执行此过程,因此每当我更改正在序列化的类型时,我都不需要手动更改.我不能使用sgen.exe / k,因为它只生成一个类型的默认XmlSerializer而不是我需要使用覆盖的类型.是否有另一种方法来生成或捕获由XmlSerializer创建的.cs文件?
解决方法
将此设置为on将在本地编译它们,以便它们可以与您的解决方案一起部署.它们也可以使用Sgen.exe工具进行编译.有关详细信息,请参阅here.
Generate serialization assembly
Specifies whether the compiler will use the XML Serializer Generator
Tool (Sgen.exe) to create XML serialization assemblies. Serialization
assemblies can improve the startup performance of XmlSerializer if you
have used that class to serialize types in your code. By default,this
option is set to Auto,which specifies that serialization assemblies
be generated only if you have used XmlSerializer to encode types in
your code to XML. Off specifies that serialization assemblies never be
generated,regardless of whether your code uses XmlSerializer. On
specifies that serialization assemblies always be generated.
Serialization assemblies are named TypeName.XmlSerializers.dll. For
more @R_718_4045@ion,see 07001.
从上次评论中我看到了你的问题.请参阅此question,我相信如果您使用XmlAttributeOverrides将始终生成程序集.
因此,如果您无法启动csc.exe,请不要使用XmlAttributeOverrides.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。