我最近安装了 Visual Studio 2012。
但是,安装后,以前在 Visual Studio 2010 中正常工作的项目开始抛出并崩溃,出现以下错误:
'System.TypeInitializationException:'MyType' 的类型初始化程序引发了异常。 ---> System.IO.FileNotFoundException:无法加载文件或程序集“MyAssembly.XmlSerializers”或其依赖项之一。该系统找不到指定的文件。
在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名、字符串代码库、证据 assemblySecurity、RuntimeAssembly locationHint、StackCrawlMark 和 stackMark、IntPtr pPrivHostBinder、布尔 throwOnFileNotFound、布尔 forIntrospection、布尔suppressSecurityChecks)
在 System.Reflection.RuntimeAssembly.nLoad(AssemblyName 文件名、字符串代码库、证据 assemblySecurity、RuntimeAssembly locationHint、StackCrawlMark 和 stackMark、IntPtr pPrivHostBinder、布尔 throwOnFileNotFound、布尔 forIntrospection、布尔suppressSecurityChecks)
我确实 not
将项目升级到 VS2012,我像以前一样在 VS2010 之外运行它。我没有对项目本身进行任何更改。唯一的变化是我在机器上安装了 VS2012(和 .NET 4.5)。
什么可能导致这个意想不到的问题?
对我来说,问题是当您更新 Visual Studio 时,VS 开发人员认为您需要将设置重置为默认值。所以他们从参考中删除了 System.XMLSerializers,他们从
Tools -> Options -> Debugging -> General
菜单中禁用了“启用源服务器支持”。添加上述参考和更新设置使错误消失。