【发布时间】:2012-02-13 08:57:57
【问题描述】:
问题
我在 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 和清单并没有解决问题。
- 我从
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 时,它不起作用。我用C:\windows\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 中的DLL 和相应的清单文件再次重复了这件事。它也没有帮助。我遇到了同样的错误。
在这两种情况下,我在事件查看器 > 系统中都收到以下错误。
事件 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 和清单并没有解决问题。
- 我从
Windows XP 机器的
C:\winnt\winsxs\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700(我开发和构建 foo.exe 的地方) 到 Windows Server 2003 的C:\foo(我正在尝试运行 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 和清单已修复此问题。
- 将
msvcm80.dll、msvcp80.dll、msvcr80.dll和Microsoft.VC80.CRT.manifest从 Windows XP 机器(我开发和构建 foo.exe)的C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT复制到 Windows Server 2003 机器(我在哪里)的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) 可以解决此问题。但它没有。从开发机器的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
【问题讨论】:
-
你可以从版本号看出。您的开发机器的版本为 6195,但您使用的 redist 版本非常旧:42 和 762。自 SP1 以来有几个安全补丁。最简单的方法是创建一个安装项目。
-
This 可能就是您要找的。span>
-
确定构建所需的 redist 版本的最简单方法是在构建项目时检查 Visual Studio 创建的清单文件。我的地址是
Mine was located at C:\Foo\Release\Foo.exe.intermediate.manifest。我在下面对我自己的问题的回答中对此进行了详细说明。
标签: c++ visual-c++ side-by-side