如何在头文件中指定并排程序集的清单?

时间:2009-12-29 03:46:00

标签: c++ windows visual-studio-2008 manifest

我正在使用MSMQ在Visual C ++ 2008中进行开发。在Windows Vista中,应用程序无法找到在C:\ Windows \ winsxs> cd x86_microsoft-windows-msmq-runtime-core_31bf3856ad364e35_6中找到的mqrt.dll。 0.6002.18005_none_574cf1cdb624ee17 \ mqrt.dll。

WinSxS中清单的描述是:

<assembly xmlns="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0" description="MSMQ core runtime component." displayName="MSMQ Core runtime component" company="Microsoft" copyright="Copyright (c) Microsoft Corporation. All Rights Reserved." creationTimeStamp="2005-03-11T01:47:18" lastUpdateTimeStamp="2005-03-11T01:48:59">
  <assemblyIdentity name="Microsoft-Windows-msmq-runtime-core" version="6.0.6002.18005" processorArchitecture="x86" language="neutral" buildType="release" publicKeyToken="31bf3856ad364e35" versionScope="nonSxS" />

我在我的头文件中添加了#pragma注释:

#pragma comment(linker, "\"/manifestdependency:name='Microsoft-Windows-msmq-runtime-core' version='6.0.6002.18005' processorArchitecture='x86' publicKeyToken='31bf3856ad364e35' language='neutral'\"")

使用mt.exe将清单嵌入到exe中。但它不起作用。 sxstrace中的错误消息是:

INFO: Resolving reference Microsoft-Windows-msmq-runtime-core,processorArchitecture="x86",publicKeyToken="31bf3856ad364e35",version="6.0.6002.18005".
    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: No publisher policy found.
                INFO: No binding policy redirect found.
            INFO: Begin assembly probing.
                INFO: Did not find the assembly in WinSxS.
                INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft-Windows-msmq-runtime-core\6.0.6002.18005__31bf3856ad364e35\Microsoft-Windows-msmq-runtime-core.DLL.
                INFO: Attempt to probe manifest at c:\qt\datamon\bin\Microsoft-Windows-msmq-runtime-core.DLL.
                INFO: Attempt to probe manifest at c:\qt\datamon\bin\Microsoft-Windows-msmq-runtime-core.MANIFEST.
                INFO: Attempt to probe manifest at c:\qt\datamon\bin\Microsoft-Windows-msmq-runtime-core\Microsoft-Windows-msmq-runtime-core.DLL.
                INFO: Attempt to probe manifest at c:\qt\datamon\bin\Microsoft-Windows-msmq-runtime-core\Microsoft-Windows-msmq-runtime-core.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference Microsoft-Windows-msmq-runtime-core,processorArchitecture="x86",publicKeyToken="31bf3856ad364e35",version="6.0.6002.18005".
ERROR: Activation Context generation failed.

我尝试了以下编译指示,但WinSxS甚至没有尝试解析msmq(可能是因为versionScope属性):

#pragma comment(linker, "\"/manifestdependency:name='Microsoft-Windows-msmq-runtime-core' version='6.0.6002.18005' processorArchitecture='x86' publicKeyToken='31bf3856ad364e35' language='neutral' buildType='release' versionScope='nonSxS'\"")

使用什么是正确的编译指示?

1 个答案:

答案 0 :(得分:0)

我真的不知道为什么没找到装配。当我遇到这样的麻烦时,我从SysInternals(现在托管在microsoft.com)获得了Process Monitor并观看了所有文件访问WinSxS商店。

iirc,清单探测是通过与应用程序进程不同的进程完成的,所以不要过滤自己的EXE名称。

无论如何,它试图寻找的文件夹显然与我案例中存在的文件夹不同,这给了我一个可靠的调查途径。