FileNotFoundException for mscorlib.XmlSerializers.DLL, which doesn't exist

馋奶兔 提交于 2019-11-30 08:48:07

I'm guessing now. but:

  1. The system might be generating a serializer for the whole of mscorlib, which could be very slow.
  2. You could probably avoid this by wrapping the system type in your own type and serialising that instead - then you'd get a serializer for your own assembly.
  3. You might be able to build the serializer for mscorlib with sgen.exe, which was the old way of building serializer dlls before it got integrated into VS.

The delay is because, having been unable to find the custom serializer dll, the system is building the equivalent code (which is very time-consuming) on the fly.

The way to avoid the delay is to have the system build the DLL, and make sure it's available to the .EXE - have you tried this?

Okay, so I ran into this problem and have found a solution for it specific to my area.

This occurred because I was trying to serialize a list into an XML document (file) without an XML root attribute. Once I added the following files, the error goes away.

XmlRootAttribute rootAttribute = new XmlRootAttribute();
rootAttribute.ElementName = "SomeRootName";
rootAttribute.IsNullable = true;

Dunno if it'll fix your problem, but it fixed mine.

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