VS2015: XAML Designer: Error: “System.IO.FileNotFoundException The system cannot find the file specified. (Exception from HRESULT: 0x80070002”
在Visual Studio 2015 + SP1中,XAML设计器显示此错误:
1 2 3 4 5 6 7 8 9 10 | 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建议,请参阅在XAML Designer中调试或禁用项目代码。
造成此问题的原因是我正在使用MEF,而我正在从事的项目缺少入门项目所需的某些程序集。
当我添加所需的程序集时,错误消失了,并且XAML预览再次开始工作。
该问题再次出现,因此我确保一切都以" Any CPU"的形式进行构建。
错误消失了,XAML预览再次开始工作。
该问题再次出现,因此我最终创建了一个单独的解决方案,该解决方案仅链接到我要预览的项目。 这很好用,并且在查看XAML预览时要快得多。