在没有安装VS Redistributables的情况下修复MFC应用程序中的并排配置错误

时间:2013-11-12 03:19:57

标签: c++ winapi visual-c++ dll mfc

我正在创建一个非常小的MFC应用程序TestEnumProcs.exe,它没有很多依赖项。这是“Dependency Walker”的截图:

enter image description here

我获得了Microsoft的MFC可再发行文件mfc90u.dllmsvcr90.dll,并将它们放在与我TestEnumProcs.exe相同的文件夹中,但是当我尝试在我的一台旧电脑上运行它时,我得到了这个错误:

enter image description here

  

应用程序无法启动,因为它并排   配置不正确......

事件日志给了我三条错误消息:

  

“J:\ TestEnumProcs.exe”的激活上下文生成失败。   附属大会   Microsoft.VC90.MFC,ProcessorArchitecture用于= “86” 公钥= “1fc8b3b9a1e18e3b”,类型= “Win32的”,版本= “9.0.21022.8”   无法找到。请使用sxstrace.exe进行详细诊断。

然后我尝试使用sxstrace.exe运行跟踪,然后是它给我的结果:

=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = x86
    CultureFallBacks = en-US;en
    ManifestPath = J:\TestEnumProcs.exe
    AssemblyDirectory = J:\
    Application Config File = 
-----------------
INFO: Parsing Manifest File J:\TestEnumProcs.exe.
    INFO: Manifest Definition Identity is (null).
    INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
    INFO: Reference: Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_f47c47b2f658b4a8.manifest
                INFO: Publisher Policy redirected assembly version.
                INFO: Post policy assembly identity is Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926".
            INFO: Begin assembly probing.
                INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest.
                INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC90.CRT.mui,language="*",processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926".
    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture en-US.
            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.VC90.CRT.mui\9.0.30729.4926_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL.
                INFO: Did not find manifest for culture en-US.
            INFO: End assembly probing.
        INFO: Resolving reference for culture en.
            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.VC90.CRT.mui\9.0.30729.4926_en_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL.
                INFO: Did not find manifest for culture en.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    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.VC90.MFC\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC.MANIFEST.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC\Microsoft.VC90.MFC.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.

=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = x86
    CultureFallBacks = en-US;en
    ManifestPath = J:\TestEnumProcs.exe
    AssemblyDirectory = J:\
    Application Config File = 
-----------------
INFO: Parsing Manifest File J:\TestEnumProcs.exe.
    INFO: Manifest Definition Identity is (null).
    INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
    INFO: Reference: Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8"
INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_f47c47b2f658b4a8.manifest
                INFO: Publisher Policy redirected assembly version.
                INFO: Post policy assembly identity is Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926".
            INFO: Begin assembly probing.
                INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest.
                INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC90.CRT.mui,language="*",processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926".
    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture en-US.
            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.VC90.CRT.mui\9.0.30729.4926_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL.
                INFO: Did not find manifest for culture en-US.
            INFO: End assembly probing.
        INFO: Resolving reference for culture en.
            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.VC90.CRT.mui\9.0.30729.4926_en_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL.
                INFO: Did not find manifest for culture en.
            INFO: End assembly probing.
INFO: Resolving reference Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
    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.VC90.MFC\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC.MANIFEST.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC\Microsoft.VC90.MFC.DLL.
                INFO: Attempt to probe manifest at J:\Microsoft.VC90.MFC\Microsoft.VC90.MFC.MANIFEST.
                INFO: Did not find manifest for culture Neutral.
            INFO: End assembly probing.
    ERROR: Cannot resolve reference Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.

我知道可以通过在该系统上安装“ MFC Redistributable Package ”来修复此问题,但我真的想避免这种情况,并尝试通过添加缺少的DLL来解决此问题。

知道怎么做吗?

4 个答案:

答案 0 :(得分:4)

我在Codeproject上为VS-2005写了一篇关于此事的文章。

您可以在blog上找到VS-2008的代码。它是德语,但您只需要包含文件。其余的和解释可以在CodeProject文章中找到。

使用包含文件,您不必手动更改清单。只需使用包含文件并设置一些定义即可完成。

答案 1 :(得分:3)

跟踪显示msvcr90.dll存在于并排缓存中,但mfc90u.dll不存在。非常不寻常,闻起来像是另一个安装程序在该机器上运行之前只需要部署它。

本地部署在技术上是可行的,它需要对清单进行手术。您无法完全删除它们,CRT中内置了一个检查,用于验证它们是否存在,如果不是,则应用程序将失败并使用R6034。

手术改变了清单,从并排切换到私人组件。这要求从清单条目中删除“publicKeyToken”元素。还必须将DLL的私有副本复制到具有正确名称和调整清单的目录中。这些步骤在this blog post中列出。

运行vcredist安装程序显然更简单,更不容易出错。

答案 2 :(得分:1)

看看你是否可以说服链接器在构建时吐出一个库和DLL依赖项列表。然后你从你的开发机器中捕获它们并静态地包含它们。有点痛苦。

在我快速浏览linker command line arguments,时,我会深入了解一些内容:

我希望你能够确切地看到你挖掘时的依赖关系。

对于它的价值,compiler的等效命令行参数是/showIncludes

答案 3 :(得分:0)

在2017年通过安装以下解决方案: Microsoft Visual C ++ 2010 SP1可再发行组件包(x86)

https://www.microsoft.com/en-us/download/details.aspx?id=8328

Windows 10和装有Visual Studio的PC将需要此修复程序。