1

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?

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
WJM
  • 1,137
  • 1
  • 15
  • 30
  • Hard to guess, this works just fine in VS2013. You didn't follow the instructions in the blog post to the letter, you at least changed the TargetPlatformVersion value. What else did you change? – Hans Passant Nov 29 '14 at 14:38
  • I made a seperate solution which does work. I compared all the references to my first project but I cannot find any differences. Is there any way to check which assemblies are causing the error and where? – WJM Dec 01 '14 at 12:09
  • I am also facing this issue. Has anyone identified what causes the error above? The same project does not suffer from this compile error in VS2012, only VS2013. I however need it to compile in VS2013, so I can publish as a click-once. – Anansi Mar 01 '15 at 16:32
  • @Anansi, this link http://stackoverflow.com/a/32810288/1948785 might help – eeadev Sep 28 '15 at 09:13

2 Answers2

2

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.

Michael Geier
  • 1,653
  • 1
  • 16
  • 18
0

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

Community
  • 1
  • 1
eeadev
  • 3,662
  • 8
  • 47
  • 100