问题
我在 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;资料来源:并排
Dependent Assembly Microsoft.VC80.CRT could not be found and Last Error was
The referenced assembly is not installed on your system.
事件 ID:59;资料来源:并排
Resolve Partial Assembly failed for Microsoft.VC80.CRT.
Reference error message: The referenced assembly is not installed on your system.
事件 ID:59;资料来源:并排
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 和清单并没有解决它。
- 我复制
了
msvcm80.dll
,从msvcp80.dll
到。msvcr80.dll
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd
C:\foo
- 接下来,我将其复制并重
C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifest
命名C:\foo
为Microsoft.VC80.CRT.manifest
.
清单文件的第四行如下所示:
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.42"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
这次我尝试运行 C:\foo\foo.exe 时,它不起作用。我再次使用 DLLC:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700
和相应的清单文件重复了这件事。它也没有帮助。我得到了同样的错误。
在这两种情况下,我在事件查看器 > 系统中都遇到了以下错误。
事件 ID:34;资料来源:并排
Component identity found in manifest does not match the identity of the component requested
事件 ID:58;资料来源:并排
Syntax error in manifest or policy file "C:\foo\Microsoft.VC80.CRT.MANIFEST" on line 4.
事件 ID:59;资料来源:并排
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 和清单并没有修复它。
- 我将
msvcm80.dll
,msvcp80.dll
和msvcr80.dll
从C:\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.manifest
命名C:\foo
为Microsoft.VC80.CRT.manifest
.
清单文件的第四行如下所示:
<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 和清单修复了它。
- 从Windows XP 机器(我开发和构建 foo.exe)复制到Windows Server
msvcm80.dll
2003机器(我试图运行它)。msvcp80.dll
msvcr80.dll
Microsoft.VC80.CRT.manifest
C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT
C:\foo
清单文件的第四行如下所示:
<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)可以修复它。但它没有。从开发机器的文件夹中复制 DLL 和清单文件C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT
修复了它。为什么会这样?
构建选项
以防万一,它可以帮助您回答我的问题。这是我从 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