Could not load Windows.winmd

戏子无情 提交于 2019-12-06 12:49:41

问题


I am following the following example from here to use WinRT API's in a Win32 Application.

I added references to System.Runtime and System.Runtime.InteropServices.WindowsRunTime but when I add the reference to Windows.winmd

I get the following error:

Error 1 Problem generating manifest. Could not load file or assembly 'C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd' or one of its dependencies. Attempt to load a program with an incorrect format.

I tried various configurations using different .NET frameworks and versions of Visual Studio. What can I try?


回答1:


It seems that the setting

<GenerateManifests>true</GenerateManifests>

in the project file (e.g. .csproj) is not compatible with winmd references.

This setting is added when enabling the ClickOnce security settings (Project Properties => Security => Enabling ClickOnce security settings checkbox).

So far I could not find a way to fix the concrete problem, but I found a workaround, which works for my case: I just created a separate Class Library project in my solution, which the main project references. In the class library project file I added the line

<TargetPlatformVersion>8.0</TargetPlatformVersion>

as described in the referenced article.

The library project compiles and also the main project can use the dll without problems.




回答2:


I solved a very similar problem following this stackoverflow solution which basically makes u publish excluding the winmd.



来源:https://stackoverflow.com/questions/27203105/could-not-load-windows-winmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!