Could not load file or assembly Windows.winmd' Could not load file or assembly Windows.winmd' wpf wpf

Could not load file or assembly Windows.winmd'


Yes, the Windows.winmd file you added as a reference is an obstacle to getting the project deployed. The tools you use get confused about its content, it looks just like a .NET assembly. But it is not, the .winmd file format is an extension of the COM type library format of old. For WinRT, they used the metadata format of .NET to get past the restrictions of the TLB file format.

That was a pretty good idea, many .NET tools can use the metadata as-is. Like compilers and disassemblers, they didn't have to put all that infrastructure into place. But it strictly plays the role of a reference assembly, only the compiler uses its content and it should never be deployed. Right now you don't like that good idea too much :)

It is however very easy to fix for a ClickOnce deployment. Use Project > Properties > Publish tab > Application Files button. Change the "Publish Status" selection for Windows.winmd to "Exclude". Sample project screen-shot:

enter image description here


It isn't very clear what you mean by "Microsoft Installer", I'll assume you talk about a Setup Project. Although removed from Visual Studio due to chronic problems, it is still available in the gallery.

That's a harder nut to crack, you'd normally use the Add > Project Output context menu entry to let it figure out the dependencies. That doesn't work anymore, it dies with miserable non-descript error message:

ERROR: An error occurred while validating. HRESULT = '80070057'

The error code means "Invalid parameter", that doesn't help narrow down the problem. But you can safely assume that it dies on trying to resolve the Windows.winmd reference in the .exe assembly.

The workaround is to not let it auto-detect the dependencies but pick them yourself. From the editor screen titled "File System on Target machine", select the Application Folder. Right-click "Primary output from ..." and select Delete.

Right-click Application Folder > Add > File and pick the project's .exe file from the bin\Release folder. Repeat for other files, you can use the file listing you got in the ClickOnce application files listing as a guide.

Build the project, you now get:

WARNING: Unable to find dependency 'WINDOWS' (Signature='(null)' Version='255.255.255.255') of assembly 'WindowsFormsApplication144.exe'

Which is entirely benign, we don't want it to find it, the Setup.exe program works fine.