繁体   English   中英

修复不安装VS Redistributables的MFC应用程序中的并行配置错误

[英]Fix side-by-side configuration error in MFC application w/o installing VS Redistributables

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

在此处输入图片说明

我获得了Microsoft的MFC可再发行文件mfc90u.dllmsvcr90.dll ,并将它们放置在与TestEnumProcs.exe相同的文件夹中,但是当我尝试在其中一台较旧的计算机上运行它时,出现此错误:

在此处输入图片说明

该应用程序无法启动,因为其并行配置不正确...

事件日志给了我三个错误消息,如下所示:

“ J:\\ TestEnumProcs.exe”的激活上下文生成失败。 找不到从属程序Microsoft.VC90.MFC,processorArchitecture =“ x86”,publicKeyToken =“ 1fc8b3b9a1e18e3b”,type =“ win32”,version =“ 9.0.21022.8”。 请使用sxstrace.exe进行详细诊断。

然后,我尝试使用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来解决此问题。

任何想法如何做到这一点?

我在Codeproject上针对VS-2005撰写了有关此文章。

您可以在我的博客上找到VS-2008的代码。 它是德语,但只需要包含文件。 其余内容和说明可在CodeProject文章中找到。

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

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

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

手术会将清单更改为从并排切换到私人装配。 这要求从清单条目中删除“ publicKeyToken”元素。 DLL的私有副本也必须复制到具有正确名称和经过调整的清单的目录中。 本博客文章中概述了这些步骤。

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

查看您是否可以说服链接器在构建时吐出库和DLL依赖项列表。 然后,从您的开发机上搜寻它们并静态地包含它们。 有点痛苦。

我快速浏览了链接器命令行参数,下面是一些我要研究的内容:

我希望您在挖掘时应该能够准确看到依赖项。

就其价值而言, 编译器的等效命令行参数为/showIncludes

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

https://www.microsoft.com/zh-cn/download/details.aspx?id=8328

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM