c++ - 当我在一台机器上开发一个 EXE 并在另一台机器上运行它时,为什么安装 vcredist_x86.exe 不能修复 SideBySide 错误?

标签 c++ visual-c++ side-by-side

问题

我在 Windows XP Professional Version 2002 Service Pack 3 上使用 Microsoft Visual Studio 2005 Verison 8.0.50727.762 (SP.050727-7600) 编写了一个名为“Foo”的 C++ 项目。我将该项目构建到 Foo.exe 中。然后,我将文件 Foo.exe 复制到 Windows Server 2003 Enterprise Edition Service Pack 2。当我尝试运行它时,它失败并出现此错误,

C:\foo.exe
The application has failed to start because the application configuration is incorrect.
Reinstalling the application may fix the problem.

在事件查看器 > 系统中,记录了三个事件。

事件 ID:32;来源:SideBySide
Dependent Assembly Microsoft.VC80.CRT could not be found and Last Error was
The referenced assembly is not installed on your system.

事件 ID:59;来源:SideBySide
Resolve Partial Assembly failed for Microsoft.VC80.CRT.
Reference error message: The referenced assembly is not installed on your system.

事件 ID:59;来源:SideBySide
Generate Activation Context failed for C:\foo\Foo.exe.
Reference error message: The referenced assembly is not installed on your system.

安装 Microsoft Visual C++ 2005 Redistributable 并没有修复它
  • http://www.microsoft.com/download/en/details.aspx?id=3387 下载了 vcredist_x86.exe
  • 安装了它。安装程序创建了一个名为 C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd 的文件夹。 .

  • 从“添加或删除程序”中找到的该软件版本为“8.0.50727.42”。

    在尝试运行 C:\foo\foo.exe 时,我遇到了与上述相同的错误。

    安装 Microsoft Visual C++ 2005 SP1 Redistributable 并没有修复它
  • http://www.microsoft.com/download/en/details.aspx?id=5638 下载了 vcredist_x86.exe
  • 安装了它。安装程序创建了一个名为:C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 的文件夹.

  • 从“添加或删除程序”中找到的该软件版本为“8.0.56336”。

    在尝试运行 C:\foo\foo.exe 时,我遇到了与上述相同的错误。

    从同一台机器(我运行 EXE 的地方)复制 CRT DLL 和 list 并没有修复它。
  • 我复制了 msvcm80.dll , msvcp80.dllmsvcr80.dllC:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acdC:\foo .
  • 接下来我复制了C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifestC:\foo并将其重命名为 Microsoft.VC80.CRT.manifest .

  • list 文件的第四行如下所示:
    <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.42"
                      processorArchitecture="x86"
                      publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    

    这次当我尝试运行 C:\foo\foo.exe 时,它​​不起作用。我用 C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 中的 DLL 再次重复了这件事和相应的 list 文件。它也没有帮助。我得到了同样的错误。

    在这两种情况下,我都在事件查看器 > 系统中收到以下错误。

    事件 ID:34;来源:SideBySide
    Component identity found in manifest does not match the identity of the component requested
    

    事件 ID:58;来源:SideBySide
    Syntax error in manifest or policy file "C:\foo\Microsoft.VC80.CRT.MANIFEST" on line 4.
    

    事件 ID:59;来源:SideBySide
    Generate Activation Context failed for C:\foo\Foo.exe. Reference error message: The manifest file contains one or more syntax errors.
    

    从 Windows XP 机器(我在其中构建 EXE)复制 CRT DLL 和 list 并没有修复它。
  • 我复制了 msvcm80.dll , msvcp80.dllmsvcr80.dllC:\winnt\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 Windows XP 机器(我开发和构建 foo.exe 的地方)
    C:\foo Windows Server 2003(我正在尝试运行 foo.exe)。
  • 接下来我复制了C:\winnt\winsxs\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.manifestC:\foo并将其重命名为 Microsoft.VC80.CRT.manifest .

  • list 文件的第四行如下所示:
    <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.762"
                      processorArchitecture="x86"
                      publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    

    现在尝试运行 C:\foo\foo.exe 时,我遇到了上一节中提到的相同错误。

    从 Visual Studio 文件夹复制 CRT DLL 和 list 修复了它。
  • 已复制 msvcm80.dll , msvcp80.dll , msvcr80.dllMicrosoft.VC80.CRT.manifest来自 C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT Windows XP 机器(我在其中开发和构建 foo.exe)到 C:\foo Windows Server 2003 机器(我正在尝试运行它)。

  • list 文件的第四行如下所示:
    <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.6195"
                      processorArchitecture="x86"
                      publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    

    这次我可以毫无问题地运行 C:\foo\foo.exe。

    问题

    我期待安装“Microsoft Visual C++ 2005 SP1 Redistributable”(vcredist_x86.exe),如第二种方法所述会修复它。但它没有。从 C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT 复制 DLL 和 list 文件开发机器的文件夹修复了它。为什么会这样?

    构建选项

    以防万一,它可以帮助您回答我的问题。这是我从 Visual Studio 项目属性中选取的编译器和链接器选项:

    配置属性 > C/C++ > 命令行:
    /O2 /GL /D "_MBCS" /FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /nologo /c /Wp64 /Zi /TP /errorReport:prompt
    配置属性 > 链接器 > 命令行:
    /OUT:"C:\MixedBag\Release\Foo.exe" /NOLOGO /MANIFEST /MANIFESTFILE:"Release\Foo.exe.intermediate.manifest" /DEBUG /PDB:"c:\MixedBag\release\Foo.pdb" /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

    最佳答案

    我会回答我自己的问题。 Hans Passant 和 Luke 对问题的评论有所帮助。

    我下载了 Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update并将其安装在我试图运行的系统上 C:\foo\foo.exe .在此之后,EXE 运行良好。

    安装程序将 CRT DLL 放在 C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86 中.所以,是的,8.0.50727.6195 是我正在寻找的 CRT DLL 版本,正如 Hans Passant 所说的那样。

    确定此版本的最简单方法是在开发系统上构建我的项目时查看 Visual Studio 生成的 list 文件。我的位于 C:\Foo\Release\Foo.exe.intermediate.manifest .它有一个这样的标签:

    <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.6195'
                      processorArchitecture='x86'
                      publicKeyToken='1fc8b3b9a1e18e3b' />
    

    所以,这是我需要 8.0.50727.6195 版本的 DLL 的线索。剩下的就是搜索正确的 vcredist_x86.exe,它恰好在我在第二段中提到的 URL 中。该 URL 中的页面包含指向 KB2538242 的链接。它显示了将由安装程序安装的 DLL 的版本号。

    注意:正如 Elie 在 a different answer 中提到的那样对于这个问题,由于这是一个 32 位应用程序,因此无论该系统是否为 32 位 Windows 系统,都需要在应该运行此应用程序的系统上安装 vcredist_x86.exe(而不是 vcredist_x64.exe)或 64 位 Windows 系统。再一次,.manifest 文件在 processorArchitecture 中提供了这个线索。属性。

    关于c++ - 当我在一台机器上开发一个 EXE 并在另一台机器上运行它时,为什么安装 vcredist_x86.exe 不能修复 SideBySide 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8913543/

    相关文章:

    c++ - 调试版本找不到调试运行时 DLL

    .net - RegFree COM 从 C# 工作,而不是从 VBA 工作

    c++ - 返回指向 protected 内部类元素的指针

    c++ - 无法推断可变参数模板的模板类型

    c++ - 如何将目录路径作为进程的命令行传递?

    c++ - IntelliSense 显示 CComPtr<T> 的不同函数集,具体取决于我使用的是点运算符还是箭头运算符

    c# - .NET 可执行文件在被新版本覆盖后不起作用

    c++ - 为什么在C++中收到重新定义错误?

    c++ - 用双链表实现的堆栈的一个错误

    visual-c++ - 什么时候需要使用FreeHGlobal()?