0

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

在此处输入图像描述

我获得了 Microsoft 的 MFC 可再发行文件mfc90u.dll并将msvcr90.dll它们放在与我TestEnumProcs.exe的 .

在此处输入图像描述

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

事件日志给了我三个这样的错误消息:

“J:\TestEnumProcs.exe”的激活上下文生成失败。相关程序集 Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="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

4 回答 4

4

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

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

使用包含文件,您不必手动更改清单。这一切都是通过使用包含文件并设置一些定义来完成的。

于 2013-11-12T07:05:54.360 回答
3

跟踪显示 msvcr90.dll 存在于并行缓存中,但 mfc90u.dll 不存在。相当不寻常,闻起来像是在该机器上运行了另一个安装程序,然后才部署它需要它。

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

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

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

于 2013-11-12T04:39:34.853 回答
1

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

在我快速浏览链接器命令行参数时,我会深入研究以下几个:

我希望如果你挖掘,你应该能够准确地看到依赖关系是什么。

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

于 2013-11-12T04:46:41.177 回答
0

通过安装在 2017 年解决:Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)

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

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

于 2018-07-22T11:57:42.693 回答