无法加载文件或程序集Windows.winmd“加载、文件、程序、winmd

2023-09-05 00:15:41 作者:爱恨随心

我的WPF的桌面应用程序使用WinRT的类为好。

My WPF Desktop app is using WinRT classes as well.

为了做到这一点我按照这个教程的https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applications.

In order to do that I follow this tutorial https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applications.

精细,它的工作原理。

现在,当我尝试生成msi文件(我试过都与使用Microsoft Installer和ClickOnce的),我收到此错误:

Now when I try to generate the msi file (I tried both with using Microsoft Installer and ClickOnce), I am getting this error:

问题产生的清单。无法加载文件或程序集C:\ Program Files文件(x86)的\的Windows套件\ 8.1 \参考资料\ CommonConfiguration \中性\ Windows.winmd或它的某一个依赖。试图用不正确的格式加载程序。的

我已经试过禁用的ClickOnce的建议here,与清洗项目,并删除ASP.NET临时不同的.NET框架中。

I already tried with disabling the ClickOnce as suggested here, with cleaning the project and with deleting ASP.NET temporary of the different NET framework.

这是我的启动标签在我的app.config                    

This is my startup tag in my app.config

我使用VS2015和C# 我怎样才能解决这个问题,并生成我的MSI?

I am using VS2015 and C# How can I fix it and generate my msi?

PS:我在生成另一个MSI用一个简单的WPF桌面应用程序没有问题

PS: I have no problem in generating another msi with a simple WPF desktop app.

推荐答案

是的,Windows.winmd您添加作为参考是一个障碍,以获得部署项目文件。您使用弄不清楚其内容的工具,它的看起来的就像一个.NET程序集。但它不是,则.winmd文件格式是旧COM类型库格式的扩展。对于WinRT的,他们使用.NET的元数据格式,让过去的TLB文件格式的限制。

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.

这是一个pretty的好主意,许多.NET工具可以使用元数据原样。像编译器和反汇编,他们没有把所有的基础设施到位。但是,严格扮演的引用大会的作用的,只有编译器使用它的内容,它不应该被部署。现在你不喜欢这个主意好太多了:)

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 :)

然而很容易解决的ClickOnce部署。使用项目>属性>发布选项卡>应用程序文件按钮。更改发布状态的选择Windows.winmd为排除。示例项目屏幕截图:

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:

这不是很清楚你所说的Microsoft安装程序的意思是,我会假设你谈论一个安装项目。虽然从Visual Studio删除,由于长期存在的问题,但仍然可以在画廊。

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.

这是一个很难啃的骨头,你通常使用Add>项目输出上​​下文菜单项,让它计算出的依赖关系。这不工作了,用凄惨非描述性错误消息去世:

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:

错误:在验证时发生错误。 HRESULT ='80070057'

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

错误code的意思是无效的参数,这不利于缩小问题。不过,你可以放心地认为它死在试图解决的。exe程序集的Windows.winmd参考。

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.

右键单击应用程序文件夹>添加>文件,并选择项目从bin \ Release文件夹的.exe文件。重复其他文件,你可以使用其中列出了在ClickOnce应用程序文件为指导,列出了该文件。

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:

警告:找不到依赖程序集的窗口(签名='(空)'版本=255.255.255.255)WindowsFormsApplication144.exe

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

这完全是良性的,我们不希望它找到它,Setup.exe程序工作正常。

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