加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 用于mscorlib.XmlSerializers.DLL的FileNotFoundException

发布时间:2020-12-15 06:34:18 所属栏目:百科 来源:网络整理
导读:我正在使用XmlSerializer反序列化mscorelib.dll中的特定类型 XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) ); 当加载程序集时,这会引发捕获的
我正在使用XmlSerializer反序列化mscorelib.dll中的特定类型
XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );
return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) );

当加载程序集时,这会引发捕获的FileNotFoundException:

“Could not load file or assembly
‘mscorlib.XmlSerializers,
Version=2.0.0.0,Culture=neutral,
PublicKeyToken=b77a5c561934e089’ or
one of its dependencies. The system
cannot find the file specified.”

FusionLog:

=== Pre-bind state information ===
LOG: User = ###
LOG: DisplayName = mscorlib.XmlSerializers,Version=2.0.0.0,PublicKeyToken=b77a5c561934e089,processorArchitecture=x86
 (Fully-specified)
LOG: Appbase = file:///C:/localdir
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml,PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:localdirbinDebugappname.vshost.exe.Config
LOG: Using machine configuration file from c:WINDOWSMicrosoft.NETFrameworkv2.0.50727configmachine.config.
LOG: Post-policy reference: mscorlib.XmlSerializers,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,我认为DLL名称由.Net自动生成,寻找序列化程序.

您可以选择在编译优化序列化时创建myApplication.XmlSerializers.DLL,因此我认为这是框架检查的一部分.

问题在于,这似乎是导致加载应用程序的延迟 – 在这一点上似乎挂了几秒钟.

任何想法如何避免这种或加速?

解决方法

我现在猜测但:

>系统可能会为整个mscorlib生成一个串行化器,这可能非常慢.>你可以通过将系统类型包装在你自己的类型中,然后序列化,你可以避免这种情况 – 然后你会得到一个你自己的程序集的序列化程序.>您可能可以使用sgen.exe构建mscorlib的序列化程序,这是在集成到VS之前构建串行化程序dll的旧方式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读