在Visual Studio中,2015+SP1设计器显示以下错误:
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)
...截图如下:

更新
已通过微软建议修复此错误,请参阅Debugging or Disabling Project Code in XAML Designer。
发布于 2016-03-17 22:31:30
导致这个问题的原因是我使用的是MEF,而我工作的项目缺少entry项目所需的一些程序集。
当我添加所需的程序集时,错误消失了,XAML预览再次开始工作。
发布于 2016-03-17 23:58:29
问题再次出现,所以我最终创建了一个单独的解决方案,该解决方案仅链接到我打算预览的项目。这种方法工作得很好,并且在查看XAML预览时速度要快得多。
发布于 2016-03-18 23:00:28
问题再次出现,所以我确保一切都是以“任何CPU”的方式构建的。
错误消失了,XAML预览又开始工作了。

https://stackoverflow.com/questions/36062146
复制相似问题