XML Serialization assembly for non-web projects

旧巷老猫 提交于 2019-12-10 23:56:36

问题


I am attempting to solve the well known problem of automatically generated serialization assemblies in VS 2010, both VB.NET and C#. The "Generate Serialization Assemblies" option in project settings does nothing for non-web projects (see http://blog.devstone.com/aaron/archive/2008/02/07/2778.aspx et al). Thus the calls to serializers generate file i/o exceptions that are very unfortunate, and for which there is no cure. The method suggested above does not appear to work with VS2010 and SGEN still runs with /proxytypes enabled.


回答1:


Solution:

Set "Generate Serialization Assemblies" in project settings to ON as usual, then add this xml into the .proj file:

<PropertyGroup>
    <SGenUseProxyTypes>false</SGenUseProxyTypes>
    <SGenPlatformTarget>$(Platform)</SGenPlatformTarget>
</PropertyGroup>

The first line turns off the evil /proxytypes switch. The second line is required if the platform that is selected is anything other than AnyCPU. If it is omitted, then the serialization assembly is built with AnyCPU and will fail to bind to the main assembly that may be x86 or x64.



来源:https://stackoverflow.com/questions/9766655/xml-serialization-assembly-for-non-web-projects

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