Could not load file or assembly 'MyAssembly.XmlSerializers [duplicate]

孤人 提交于 2019-11-30 14:30:14

问题


I took a memory dump of IIS and while analyzing i found the error that said 'Could not load file or assembly MyAssemblyName.XmlSerializers'. In my code i am using XmlSerializer class to serialize and deserialize xml contents from xml file to custom object. When the project gets build it only creates MyAssembly.dll and MyAssembly.pdb file but not the MyAssembly.XmlSerializers.dll. Does anyone know how to enable my project to create xmlserializers.dll file?

Note: In project build tab, 'Generate serialization assembly is set to Auto.

Thanks.


回答1:


There's an answer already here. Apparently this is "expected behaviour" that MS isn't going to fix.

The first comment has a workaround:

One of the possible ways to get rid of this problem is check "Just my code" option in Tools -> Options -> Debugging -> General options




回答2:


You can also generate this assembly using Sgen.exe

For me it's located in: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools

1. open cmd command
2. cd yourProjectPath
3. sgen Project.dll

The following command creates an assembly named Project.XmlSerializers.dll for serializing all the types contained in the assembly named Project.dll.




回答3:


When you create MyAssembly.XmlSerializers.dll make sure it is same .NET version as your project. You can check that using software as dotPeek or ILSpy. I had similar problem when creating xmlserializers for my .NET 3.5 solution from visual studio, generate serialization assembly was set on for project but Sgen.exe was used from C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools and should be from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin. If your solution is in .NET 3.5 MyAssembly.XmlSerializers.dll must also be in .NET 3.5



来源:https://stackoverflow.com/questions/17755559/could-not-load-file-or-assembly-myassembly-xmlserializers

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