神奇的 .XmlSerializers’ could not be loaded.
开发webservice 时,发现无缘无故 在TFS 发布后的代码中 XXX.XmlSerializers 不在bin 上,反而在 站点的根目录下,导致管理员不同意直接 配置 Azure 上的自动部署,查明原因及解决方法。
错误信息:
Server Error in '/' Application.
Could not load file or assembly 'XXXXXXX.Service.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'XXXXXXX.Service.XmlSerializers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Source Error:
解决办法:
1,修改.NET 版本,本来是2.0 ,升级到4.0 后解决问题。
2,修改项目属性的生成,将生成序列化程序及关闭。必须删除之前的缓存,否则生成还会受影响。