无法加载MyAssembly.XmlSerializers.dll。该系统找不到指定的文件

时间:2014-01-30 19:11:54

标签: c# visual-studio

我最近安装了Visual Studio 2012.

但是,在安装之后,以前在Visual Studio 2010中正常工作的项目开始抛出并崩溃以下错误:

  

'System.TypeInitializationException:'MyType'的类型初始值设定项   抛出一个例外。 ---> System.IO.FileNotFoundException:无法   加载文件或程序集“MyAssembly.XmlSerializers”或其中一个   依赖。系统找不到指定的文件。

     

在System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,   String codeBase,Evidence assemblySecurity,RuntimeAssembly   locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,   Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)

     

在System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,   String codeBase,Evidence assemblySecurity,RuntimeAssembly   locationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,   Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)

没有将项目升级到VS2012,我像以前一样从VS2010运行它。我没有对项目本身做任何改动。唯一的变化是我在机器上安装了VS2012(和.NET 4.5)。

可能导致这个意外问题的原因是什么?

1 个答案:

答案 0 :(得分:4)

情况比我预期的要复杂一些。该程序集的XMLSerializers DLL似乎对我的解决方案中的身份验证至关重要,只需“按[F]继续运行直到出现真正的问题”并没有导致一些无关的错误。

我无法完全理解底层问题是什么,但似乎在升级Visual Studio后动态创建DLL。

我解决这个问题的方法是运行sgen工具手动创建序列化程序并将标志“Generate Serialization Assemblies”设置为Off。可以通过添加构建后的指令来自动执行该过程。

话虽如此,我不知道为什么这个问题首先出现,因为我确信我没有在VS2012中打开这个项目。

相关问题