【问题标题】:VS2015: XAML Designer: Error: "System.IO.FileNotFoundException The system cannot find the file specified. (Exception from HRESULT: 0x80070002"VS2015:XAML 设计器:错误:“System.IO.FileNotFoundException 系统找不到指定的文件。(来自 HRESULT 的异常:0x80070002”
【发布时间】:2016-03-18 23:00:52
【问题描述】:

在 Visual Studio 2015+SP1 中,XAML 设计器显示此错误:

System.IO.FileNotFoundException
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at Microsoft.MetadataReader.NativeMethods.SafeOpenFile(String fileName)
   at Microsoft.MetadataReader.FileMapping..ctor(String fileName)
   at Microsoft.MetadataReader.MetadataDispenser.OpenFileAsFileMapping(String fileName)
   at Microsoft.MetadataReader.Loader.ResolveModule(Assembly containingAssembly, String moduleName)
   at Microsoft.MetadataReader.DefaultUniverse.ResolveModule(Assembly containingAssembly, String moduleName)
   at Microsoft.MetadataReader.SimpleUniverse.Microsoft.MetadataReader.ITypeUniverse.ResolveModule(Assembly containingAssembly, String moduleName)
...

这是截图:

更新

查看 Microsoft 修复此错误的建议,请参阅 Debugging or Disabling Project Code in XAML Designer

【问题讨论】:

  • 始终或仅在您打开特定项目/xaml 文件时?
  • 刚刚使用全新的 WPF 应用程序对其进行了测试,并且运行良好。所以它一定和我正在做的项目有关。

标签: wpf xaml visual-studio-2015


【解决方案1】:

问题是因为我使用的是MEF,而我正在从事的项目缺少一些入口项目所需的程序集。

当我添加所需的程序集时,错误消失了,XAML 预览又开始工作了。

【讨论】:

    【解决方案2】:

    问题再次出现,因此我最终创建了一个单独的解决方案,该解决方案仅链接到我打算预览的项目。这很好用,而且在查看 XAML 预览时要快得多。

    【讨论】:

      【解决方案3】:

      问题再次出现,因此我确保所有内容都构建为“任何 CPU”。

      错误消失了,XAML 预览又开始工作了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-05-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多