我使用的一个序列化程序,以deserialize特定类型mscorelib.dll

XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );
return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) );

这将引发一个抓住了 FileNotFoundException 当会加载:

"未能加载文件或组件 'mscorlib.XmlSerializers, Version=2.0.0.0、文化=中性, 公钥=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我认为DLL名称具有的蜜蜂自动产生。净寻找序列化程序。

你有选择创建一个myApplication.XmlSerializers.DLL 当汇编优化的序列化,所以我假设这是框架的一部分的检查。

问题是,这似乎是造成延迟加载应用程序,它似乎要挂了几秒钟,在这一点上。

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

有帮助吗?

解决方案

我猜现在。但是:

  1. 该系统可能产生串行器的整个mscorlib,这可能会非常缓慢。
  2. 你可能可以避免这种通过包装的系统输入您自己的类型和serialising,而不是-然后你会得到一程序为自己的议会。
  3. 你也许可以建立程序,用于与mscorlib sgen.exe这是旧的方式建立器dll之前,它得到了整合到VS。

其他提示

延迟是因为,具有直无法找到的定义的程序问题,该系统是建立相当于代码(这是非常耗费时间)。

该方法可以避免的拖延是有系统生成的问题,并确保它是可用的。EXE-你有没有试过这个吗?

好了,所以我跑到这个问题和必须找到一个解决方案,它具体到我的区域。

发生这种情况因为我是试图列化列入XML文件(文件)没有一个XML根本属性。一旦我加入以下文件,错误。

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

不知道,如果它会解决你的问题,但它固定地雷。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top