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

Sus*_*Pal 41 c++ side-by-side visual-c++

问题

我在Windows XP Professional版本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企业版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.
Run Code Online (Sandbox Code Playgroud)

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

事件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.
Run Code Online (Sandbox Code Playgroud)

事件ID:59; 资料来源:SideBySide

Resolve Partial Assembly failed for Microsoft.VC80.CRT.
Reference error message: The referenced assembly is not installed on your system.
Run Code Online (Sandbox Code Playgroud)

事件ID:59; 资料来源:SideBySide

Generate Activation Context failed for C:\foo\Foo.exe.
Reference error message: The referenced assembly is not installed on your system.
Run Code Online (Sandbox Code Playgroud)

安装Microsoft Visual C++ 2005 Redistributable没有修复它

  1. http://www.microsoft.com/download/en/details.aspx?id=3387下载了vcredist_x86.exe
  2. 安装好了.安装程序创建一个文件夹,名为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没有修复它

  1. http://www.microsoft.com/download/en/details.aspx?id=5638下载了vcredist_x86.exe
  2. 安装好了.安装程序创建一个文件夹,名为: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和清单并没有解决它.

  1. 我复制msvcm80.dll,msvcp80.dllmsvcr80.dllC:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acdC:\foo.
  2. 接下来,我复制 C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifestC:\foo它改名为Microsoft.VC80.CRT.manifest.

清单文件的第四行看起来像这样:

<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.42"
                  processorArchitecture="x86"
                  publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
Run Code Online (Sandbox Code Playgroud)

当我这次尝试运行C:\ foo\foo.exe时,它无效.我再次使用DLL C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700和相应的清单文件重复此事.它没有帮助.我得到了同样的错误.

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

事件ID:34; 资料来源:SideBySide

Component identity found in manifest does not match the identity of the component requested
Run Code Online (Sandbox Code Playgroud)

事件ID:58; 资料来源:SideBySide

Syntax error in manifest or policy file "C:\foo\Microsoft.VC80.CRT.MANIFEST" on line 4.
Run Code Online (Sandbox Code Playgroud)

事件ID:59; 资料来源:SideBySide

Generate Activation Context failed for C:\foo\Foo.exe. Reference error message: The manifest file contains one or more syntax errors.
Run Code Online (Sandbox Code Playgroud)

从Windows XP机器(我构建EXE)复制CRT DLL和清单并没有解决它.

  1. 我复制msvcm80.dll,msvcp80.dll以及msvcr80.dllC:\winnt\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700Windows XP计算机(其中我公司开发和制造foo.exe的),以C:\foo在Windows Server 2003(其中我试图运行foo.exe的)的.
  2. 接下来,我复制 C:\winnt\winsxs\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.manifestC:\foo它改名为Microsoft.VC80.CRT.manifest.

清单文件的第四行看起来像这样:

<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.762"
                  processorArchitecture="x86"
                  publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
Run Code Online (Sandbox Code Playgroud)

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

从Visual Studio文件夹复制CRT DLL和清单修复它.

  1. 复制msvcm80.dll,msvcp80.dll,msvcr80.dll以及Microsoft.VC80.CRT.manifestC:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRTWindows XP计算机(其中我公司开发和制造foo.exe的)到C:\fooWindows Server 2003的计算机(其中我试图运行它).

清单文件的第四行看起来像这样:

<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.6195"
                  processorArchitecture="x86"
                  publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
Run Code Online (Sandbox Code Playgroud)

这次我可以运行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和清单文件修复了它.为什么会这样?

构建选项

如果它,它可以帮助您回答我的问题.这是我从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

Sus*_*Pal 50

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

我下载了Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC安全更新并将其安装在我尝试运行的系统上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生成的清单文件.我的位于C:\Foo\Release\Foo.exe.intermediate.manifest.它有这样的标签:

<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.6195'
                  processorArchitecture='x86'
                  publicKeyToken='1fc8b3b9a1e18e3b' />
Run Code Online (Sandbox Code Playgroud)

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

注意:正如Elie在对此问题的不同答案中提到的,由于这是一个32位应用程序,因此必须在应该运行此应用程序的系统上安装vcredist_x86.exe(而不是vcredist_x64.exe),而不管该系统是32位Windows系统还是64位Windows系统.再一次,.manifest文件在processorArchitecture属性中提供了这个线索.