.manifest文件中生成重复的行 [英] Duplicate lines being generated in .manifest file

查看:82
本文介绍了.manifest文件中生成重复的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

摘要: 我的项目使用一个需要自行注册的COM组件.该项目具有自己的自定义myapp.exe.manifest文件,其中包括两行:

SUMMARY: My project uses a COM component which needs to be self-registered. The project has it's own custom myapp.exe.manifest file, which includes the two lines:

<comInterfaceExternalProxyStub name="ICapturer" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

但是,构建项目会在实际的实时.manifest文件中生成以下文件:

However, building the project generates these files in the actual live .manifest file:

<comInterfaceExternalProxyStub name="" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" numMethods="" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" numMethods="" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="ICapturer" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

换句话说,重复的一行缺少属性值,这自然会在应用启动时引发错误.

In other words, a duplicate line with missing attribute values, which naturally throws an error when the app starts.

如果我从原始清单中删除任一源"行,则虚拟重复项和正确行都将从生成的清单中消失-即注释掉ICapturer行,并且该行及其重复项都是没有产生.

If I remove either one of the "source" lines from the original manifest, both the dummy duplicate and the correct line disappear from the generated manifest - i.e. comment out the ICapturer line, and both that line and its duplicate aren't generated.

所引用的组件将嵌入互操作"和隔离"都设置为false(请参见下面的屏幕截图).

The referenced component has both "Embed Interop" and "Isolated" set to false (see screenshot below).

鉴于Visual Studio始终希望生成清单(即使我已要求它专门使用我的文件),如何停止生成重复的行?

Given that Visual Studio will always want to generate the manifest (even though I've asked it to specifically use my file), how can I stop the duplicated lines being generated?

原始问题文本:

接着我的上一个问题,我很难理解与我的ClickOnce应用程序一起部署的COM组件.我现在已经解决了这个问题,但是它涉及到编辑生成的.manifest文件以包括一些被省略的参数.

Following on from my previous question, I had a hard time getting COM component deployed with my ClickOnce application. I've resolved this issue now, but it involved editing the generated .manifest file to include some parameters that were being omitted.

我已经将自定义清单文件放入我的项目中,但是每次构建它时,它都会重新生成几乎但不完全相同的清单.我有重复的部分:例如,在我的app.manifest中,我有:

I've put the custom manifest file into my project, but every time I build it, it regenerates a manifest that is almost, but not quite, the same. I have sections that are repeated: for example, in my app.manifest I have:

<comInterfaceExternalProxyStub name="ICapturer" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

,但生成的exe.manifest具有:

  <comInterfaceExternalProxyStub name="" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" numMethods="" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="" xmlns="urn:schemas-microsoft-com:asm.v1" />
  <comInterfaceExternalProxyStub name="" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" numMethods="" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="" xmlns="urn:schemas-microsoft-com:asm.v1" />
  <comInterfaceExternalProxyStub name="ICapturer" iid="{DCAFCA37-546E-4D0A-9C02-D3221E65FCA9}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />
  <comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

...如此重复的部分缺少名称"属性.

... so duplicated sections with missing "name" attributes.

理想情况下,我只想使用我的已知清单文件,因此我创建了该文件并将其添加到我的项目中:

Ideally, I'd like to just use my known, good manifest file, so I created that and added to my project:

但是,即使告诉Visual Studio不要生成清单文件,并根据该清单文件在我的项目中创建一个新文件,它仍然坚持摆弄它.

However, even after telling Visual Studio NOT to generate a manifest file, and creating a fresh one in my project based on that specific manifest file, it insists on fiddling with it.

如何在不添加内容并将其破坏的情况下如何生成清单文件呢?

How can I generate a manifest file that is exactly what I tell it to be, without Visual Studio adding things to it and breaking it?

我已经检查过,并且Reference'd DLL上的Isolated标志为False:

I've checked, and the Isolated flag on the Reference'd DLL is False:

有趣的是,如果我注释掉项目清单文件中的comInterfaceExternalProxyStub部分中的任何一个,则在生成的文件中会省略这两行.看来清单中的这些行确实以某种方式在生成的文件中生成了两行-它们几乎相同,但是它们缺少名称"属性.因此,为了说明这一点:在app.manifest中有这一行:

Interestingly, if I comment out either of the comInterfaceExternalProxyStub sections in project's manifest file, BOTH lines are omitted from the generated file. It does seem that the presence of those lines in my manifest is somehow generating TWO lines in the generated file - they're almost identical, but they're missing the "Name" attribute. So, to illustrate: having this one line in app.manifest:

 <comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

在实际构建中生成以下两行:

generates these TWO lines in the actual build:

<comInterfaceExternalProxyStub name="" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" numMethods="" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="" xmlns="urn:schemas-microsoft-com:asm.v1" />
<comInterfaceExternalProxyStub name="IVideoWMVSettings" iid="{1A814EC2-55A9-4FA2-99E2-2C20A897C2E7}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}" baseInterface="{00000000-0000-0000-C000-000000000046}" tlbid="{8EDAD3BB-AE5F-43B4-A2F1-B04F4130F2E0}" xmlns="urn:schemas-microsoft-com:asm.v1" />

如果我注释掉app.manifest中的comInterfaceExternalProxyStub行,则在生成的清单中出现NEITHER行.

If I comment out the comInterfaceExternalProxyStub line in app.manifest, NEITHER line appears in the generated manifest.

推荐答案

我看到了.从这个问题尚不清楚的是,当Click-Once发布者重写您的清单并添加了一次单击特定的粘稠物时,这是错误的.

I see it. What is not clear from the question is that this goes wrong when the Click-Once publisher rewrites your manifest and adds the click-once specific goo.

我尝试了一种解决方法,有多种方法可以做到这一点.例如,您可以将组件清单分开,并在主清单中使用<dependency>.没什么区别. Click-Once清单中<file>元素的记录的架构非常奇怪,请注意它如何将comInterfaceExternalProxyStub声明为file的子级.将其移动以匹配模式无效,这将导致元素完全消失.该文档完全是错误的,是麻烦的预兆.

I poked at a workaround for a while, there is more than one way to do this. You can for example keep the component manifest separate and use <dependency> in the main manifest. Made no difference. The documented schema for the <file> element in a Click-Once manifest is very strange, note how it declares comInterfaceExternalProxyStub as a child of file. Moving it to match the schema did not work, it causes the element to disappear completely. This documentation is just flat-out wrong, a harbinger of trouble.

长话短说,这是一个错误.这不是一个奇怪的错误,应用程序清单文档太少了,对于comInterfaceExternalProxyStub来说尤其如此.我有几次使用张俊峰的名字,这是在一个句子中,我在这里无法重复.

Long story short, this is a bug. It is not a strange bug, the application manifest documentation is excessively poor and especially so for comInterfaceExternalProxyStub. The several times I used Junfeng Zhang's name it was in a sentence with words I cannot repeat here.

您可以在connect.microsoft.com上报告它.奇怪的是,以前没有任何报告,但是可以肯定的是,大多数程序员都不需要它,或者没有尝试或很快放弃,而是要求用户安装COM组件作为前提条件.那是很正常的,也许您也应该采用这种方法.除此之外,手动编辑清单并删除多余的行是一种解决方法.

You can report it at connect.microsoft.com. No previous reports for this, oddly, but surely most programmers either did not need it or did not try or gave up quickly and asked the user to install the COM component as a prerequisite. That is quite normal and perhaps the approach you should take as well. Other than that, editing the manifest by hand and deleting the extra lines is a workaround.

也不要忘记尝试最明显的解决方法,comInterfaceExternalProxyStub并不经常需要,并且在程序集引用中使用Isolated属性时不会生成.绝大多数程序员的操作方式以及我之前给您的建议.只要您不使用工作线程中的COM组件,就不需要代理.

And don't forget to try to the most obvious workaround, comInterfaceExternalProxyStub is not often needed and won't be generated when you use the Isolated property in the assembly reference. The way the vast majority of programmers do it and the advice I gave you earlier. As long as you don't use the COM component from a worker thread then the proxy is not needed.

这篇关于.manifest文件中生成重复的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆