我正在使用XmlSerializer来反序列化mscorelib.dll中的特定类型
XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );
return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) );
这引发了一场被捕 FileNotFoundException
加载程序集时:
“无法加载文件或程序集 “mscorlib.XmlSerializers, 版本= 2.0.0.0,文化=中立, PublicKeyToken = b77a5c561934e089'或 其中一个依赖项。系统 找不到指定的文件。“
FusionLog:
=== Pre-bind state information ===
LOG: User = ###
LOG: DisplayName = mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86
(Fully-specified)
LOG: Appbase = file:///C:/localdir
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\localdir\bin\Debug\appname.vshost.exe.Config
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: mscorlib.XmlSerializers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86
LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/localdir/bin/Debug/mscorlib.XmlSerializers/mscorlib.XmlSerializers.EXE.
据我所知,没有mscorlib.XmlSerializers.DLL,我认为.Net的自动生成的DLL名称正在寻找序列化程序。
您可以选择在编译时创建myApplication.XmlSerializers.DLL以优化序列化,因此我认为这是框架检查它的一部分。
问题是,这似乎导致加载应用程序的延迟 - 此时似乎挂起了几秒钟。
任何想法如何避免或加快它?