序列化()不使用.XmlSerializers.dll生产与SGEN序列化、XmlSerializers、SGEN、dll

2023-09-07 10:10:50 作者:你别来我无恙

我在.NET 3.5库SGEN一步,产生正确的XYZ.XmlSerializers.dll在输出目录。 仍然有序列化性能差,我发现,.NET依然调用CSC在运行时。使用进程监视器,我看到.NET正在寻找一个名为DLLXYZ.XmlSerializers.-1378521009.dll。

I have a sgen step in my .NET 3.5 library, producing a correct XYZ.XmlSerializers.dll in the output directory. Still having poor serialization performance, I discovered that .NET was still invoking a csc at runtime. Using process monitor, I saw that .NET was searching for a dll named "XYZ.XmlSerializers.-1378521009.dll".

为什么会出现-1378521009的文件名?如何判断.NET使用由SGEN产生的'正常'的DLL?

Why is there a '-1378521009' in the filename ? How to tell .NET to use the 'normal' DLL produced by sgen ?

推荐答案

绕,未免有反射戳,这似乎当您使用XmlSerializer的(类型,String)构造的情况发生,指定自定义命名空间。尝试使用XmlSerializer(类型)的构造来代替。

Poking around a bit with Reflector, this seems to happen when you use the XmlSerializer(Type, string) constructor, specifying a custom namespace. Try using the XmlSerializer(Type) constructor instead.