简体   繁体   English

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

[英]Why installing vcredist_x86.exe doesn't fix SideBySide error when I develop an EXE on one machine and run it on another one?

Issue 问题

I wrote a C++ project called 'Foo' using Microsoft Visual Studio 2005 Verison 8.0.50727.762 (SP.050727-7600) on Windows XP Professional Version 2002 Service Pack 3. I built the project into Foo.exe. 我在Windows XP Professional版本2002 Service Pack 3上使用Microsoft Visual Studio 2005 Verison 8.0.50727.762(SP.050727-7600)编写了一个名为'Foo'的C ++项目。我将项目构建到Foo.exe中。 Then, I copied the file Foo.exe to a Windows Server 2003 Enterprise Edition Service Pack 2. When I tried to run it, it failed with this error, 然后,我将文件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.

In Event Viewer > System, three events were logged. 在事件查看器>系统中,记录了三个事件。

Event ID: 32; 事件ID:32; Source: SideBySide 资料来源:SideBySide

Dependent Assembly Microsoft.VC80.CRT could not be found and Last Error was
The referenced assembly is not installed on your system.

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

Resolve Partial Assembly failed for Microsoft.VC80.CRT.
Reference error message: The referenced assembly is not installed on your system.

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

Generate Activation Context failed for C:\foo\Foo.exe.
Reference error message: The referenced assembly is not installed on your system.

Installing Microsoft Visual C++ 2005 Redistributable didn't fix it 安装Microsoft Visual C ++ 2005 Redistributable没有修复它

  1. Downloaded vcredist_x86.exe from http://www.microsoft.com/download/en/details.aspx?id=3387 http://www.microsoft.com/download/en/details.aspx?id=3387下载了vcredist_x86.exe
  2. Installed it. 安装好了。 The installer created a folder called C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd . 安装程序创建了一个名为C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd的文件夹。

The version of this software as found from 'Add or Remove Programs' was '8.0.50727.42'. 从“添加或删除程序”中找到的该软件版本为“8.0.50727.42”。

On trying to run C:\\foo\\foo.exe, I got the same errors I described above. 在尝试运行C:\\ foo \\ foo.exe时,我得到了与上述相同的错误。

Installing Microsoft Visual C++ 2005 SP1 Redistributable didn't fix it 安装Microsoft Visual C ++ 2005 SP1 Redistributable没有修复它

  1. Downloaded vcredist_x86.exe from http://www.microsoft.com/download/en/details.aspx?id=5638 http://www.microsoft.com/download/en/details.aspx?id=5638下载了vcredist_x86.exe
  2. Installed it. 安装好了。 The installer created a folder called: C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 . 安装程序创建了一个名为C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700的文件夹。

The version of this software as found from 'Add or Remove Programs' was '8.0.56336'. 从“添加或删除程序”中找到的该软件版本为“8.0.56336”。

On trying to run C:\\foo\\foo.exe, I got the same errors I described above. 在尝试运行C:\\ foo \\ foo.exe时,我得到了与上述相同的错误。

Copying CRT DLLs and manifest from the same machine (where I'm running the EXE) didn't fix it. 从同一台机器(我正在运行EXE)复制CRT DLL和清单并没有解决它。

  1. I copied msvcm80.dll , msvcp80.dll and msvcr80.dll from C:\\WINDOWS\\WinSxS\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd to C:\\foo . 我将msvcm80.dllmsvcp80.dllmsvcr80.dllC:\\WINDOWS\\WinSxS\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acdC:\\foo
  2. Next, I copied C:\\WINDOWS\\WinSxS\\Manifests\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifest to C:\\foo and renamed it to Microsoft.VC80.CRT.manifest . 接下来,我将C:\\WINDOWS\\WinSxS\\Manifests\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifestC:\\foo并将其重命名为Microsoft.VC80.CRT.manifest

The fourth line of the manifest file looked like this: 清单文件的第四行看起来像这样:

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

When I tried running C:\\foo\\foo.exe this time, it didn't work. 当我这次尝试运行C:\\ foo \\ foo.exe时,它无效。 I repeated this thing again with the DLLs in C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 and the corresponding manifest file. 我再次使用C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700和相应的清单文件重复此操作。 It didn't help as well. 它没有帮助。 I got the same error. 我得到了同样的错误。

In both cases, I got the following errors in Event Viewer > System. 在这两种情况下,我在事件查看器>系统中收到以下错误。

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

Component identity found in manifest does not match the identity of the component requested

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

Syntax error in manifest or policy file "C:\foo\Microsoft.VC80.CRT.MANIFEST" on line 4.

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

Generate Activation Context failed for C:\foo\Foo.exe. Reference error message: The manifest file contains one or more syntax errors.

Copying CRT DLLs and manifest from the Windows XP machine (where I built the EXE) didn't fix it. 从Windows XP机器(我构建EXE)复制CRT DLL和清单并没有解决它。

  1. I copied msvcm80.dll , msvcp80.dll and msvcr80.dll from C:\\winnt\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700 of Windows XP machine (where I developed and built foo.exe) to C:\\foo of Windows Server 2003 (where I am trying to run foo.exe). 我将Windows XP机器(我开发并构建了foo.exe)的C:\\winnt\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700msvcm80.dllmsvcp80.dllmsvcr80.dll复制到C:\\foo Windows Server 2003的C:\\foo (我试图运行foo.exe)。
  2. Next, I copied C:\\winnt\\winsxs\\Manifests\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.manifest to C:\\foo and renamed it to Microsoft.VC80.CRT.manifest . 接下来,我将C:\\winnt\\winsxs\\Manifests\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700.manifestC:\\foo并将其重命名为Microsoft.VC80.CRT.manifest

The fourth line of the manifest file looked like this: 清单文件的第四行看起来像这样:

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

On trying to run C:\\foo\\foo.exe now I got the same errors mentioned in the previous section. 在尝试运行C:\\ foo \\ foo.exe时,我遇到了上一节中提到的相同错误。

Copying CRT DLLs and manifest from Visual Studio folder fixed it. 从Visual Studio文件夹复制CRT DLL和清单修复它。

  1. Copied msvcm80.dll , msvcp80.dll , msvcr80.dll and Microsoft.VC80.CRT.manifest from C:\\Program Files\\Microsoft Visual Studio 8\\VC\\redist\\x86\\Microsoft.VC80.CRT of Windows XP machine (where I developed and built foo.exe) to C:\\foo of Windows Server 2003 machine (where I am trying to run it). 从Windows XP机器的C:\\Program Files\\Microsoft Visual Studio 8\\VC\\redist\\x86\\Microsoft.VC80.CRT复制msvcm80.dllmsvcp80.dllmsvcr80.dllMicrosoft.VC80.CRT.manifest (我在哪里开发并构建了foo.exe)到Windows Server 2003机器的C:\\foo (我试图运行它)。

The fourth line of the manifest file looked like this: 清单文件的第四行看起来像这样:

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

This time I could run C:\\foo\\foo.exe without any issues. 这次我可以运行C:\\ foo \\ foo.exe而没有任何问题。

Question

I was expecting that installing 'Microsoft Visual C++ 2005 SP1 Redistributable' (vcredist_x86.exe) as described in the second approach would fix it. 我期待安装第二种方法中描述的'Microsoft Visual C ++ 2005 SP1 Redistributable'(vcredist_x86.exe)可以解决它。 But it didn't. 但事实并非如此。 Copying the DLLs and manifest files from the C:\\Program Files\\Microsoft Visual Studio 8\\VC\\redist\\x86\\Microsoft.VC80.CRT folder of the development machine fixed it. 从开发计算机的C:\\Program Files\\Microsoft Visual Studio 8\\VC\\redist\\x86\\Microsoft.VC80.CRT文件夹中复制DLL和清单文件修复了它。 Why was it so? 为什么会这样?

Build options 构建选项

In case, it helps you to answer my question. 如果它,它可以帮助您回答我的问题。 Here is the compiler and linker options I picked up from Visual Studio project properties: 这是我从Visual Studio项目属性中选择的编译器和链接器选项:

Configuration properties > C/C++ > Command Line: 配置属性> C / C ++>命令行:

/O2 /GL /D "_MBCS" /FD /EHsc /MD /Fo"Release\\\\" /Fd"Release\\vc80.pdb" /W3 /nologo /c /Wp64 /Zi /TP /errorReport:prompt

Configuration properties > Linker > Command Line: 配置属性>链接器>命令行:

/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

I'll answer my own question. 我会回答我自己的问题。 Comments to the question by Hans Passant and Luke helped. Hans Passant和Luke对这个问题的评论有所帮助。

I downloaded Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update and installed it on the system where I was trying to run C:\\foo\\foo.exe . 我下载了Microsoft Visual C ++ 2005 Service Pack 1 Redistributable Package MFC安全更新并将其安装在我尝试运行C:\\foo\\foo.exe The EXE ran fine after this. 此后EXE运行良好。

The installer placed the CRT DLLs in C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86 . 安装程序将CRT DLL放在C:\\windows\\winsxs\\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86 So, yes, 8.0.50727.6195 was the version of the CRT DLLs I was looking for as Hans Passant rightly said. 所以,是的,8.0.50727.6195是我正在寻找的CRT DLL的版本,正如Hans Passant正确地说的那样。

The easiest way to figure this version was by looking at the manifest file generated by Visual Studio while building my project on the development system. 计算此版本的最简单方法是在开发系统上构建项目时查看Visual Studio生成的清单文件。 Mine was located at C:\\Foo\\Release\\Foo.exe.intermediate.manifest . 我的位于C:\\Foo\\Release\\Foo.exe.intermediate.manifest It had a tag like this: 它有这样的标签:

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

So, this is a clue that I needed 8.0.50727.6195 version of the DLLs. 所以,这是一个线索,我需要8.0.50727.6195版本的DLL。 The rest was a matter of searching for the right vcredist_x86.exe which happened to be in the URL I have mentioned in the second paragraph. 剩下的就是搜索正确的vcredist_x86.exe,它恰好出现在我在第二段中提到的URL中。 The page in that URL contains a link to KB2538242 which shows the version numbers of the DLLs that would be installed by the installer. 该URL中的页面包含指向KB2538242的链接,该链接显示安装程序将安装的DLL的版本号。

Note: As Elie has mentioned in a different answer to this question, since this is a 32-bit application, it is necessary to install vcredist_x86.exe (not vcredist_x64.exe) on the system where this application is supposed to be run irrespective of whether that system is a 32-bit Windows system or a 64-bit Windows system. 注意:正如Elie在对此问题的不同答案中提到的,由于这是一个32位应用程序,因此必须在应该运行此应用程序的系统上安装vcredist_x86.exe(而不是vcredist_x64.exe),而不管该系统是32位Windows系统还是64位Windows系统。 Once again, the .manifest file provides this clue in the processorArchitecture attribute. 同样,.manifest文件在processorArchitecture属性中提供了这个线索。

您必须安装“Microsoft Visual C ++ 2005 Service Pack 1可再发行组件包MFC安全更新 ”,其中包括: http//www.microsoft.com/en-us/download/details.aspx?id = 26347

Here is how you fix this issue: 以下是解决此问题的方法:

You WILL STILL Get the sidebyside errors If the application being used is 32 bit and you try running it on a 64 bit OS which has the VC_REDISTx64 installed. 你仍然得到的sidebyside错误如果正在使用的应用程序是32位,并尝试在其上安装了一个VC_REDISTx64 64位操作系统上运行它。

Simple solution, you MUST ALSO LOAD THE VC_REDISTx86 on the 64 bit os 简单的解决方案,您还必须在64位操作系统上加载VC_REDISTx86

I had a somewhat related problem. 我有一个相关的问题。 Two development XP machines with VS2005 installed, call them A and B. I developed, built and ran on A. Then I copied the whole project to B. Built there. 安装了VS2005的两台开发XP机器,称它们为A和B.我开发,构建并运行A.然后我将整个项目复制到B.在那里。 Tried to run and got the same error messages mentioned by SusamPal. 试图运行并得到SusamPal提到的相同错误消息。 I realized that on B's WinSxS there were the x86_Microsoft.VC80.CRT_xxx manifests (and folders) but not the corresponding x86_Microsoft.VC80.DebugCRT_xxx ones (and why?!). 我意识到在B的WinSxS上有x86_Microsoft.VC80.CRT_xxx清单(和文件夹),但没有相应的x86_Microsoft.VC80.DebugCRT_xxx清单(以及为什么?!)。 I tried several of the dances and incantations described by SusamPal to no avail. 我尝试了SusamPal描述的几个舞蹈和咒语无济于事。 I solved the problem by copying the appropriate folders from the WinSxS of A to B AND the appropriate manifests from the WinSxs\\Manifests. 我通过将适当的文件夹从A的WinSxS复制到B以及WinSxs \\ Manifests中的相应清单来解决了这个问题。

Although my application was 虽然我的申请是

developed on Win 2k8 R2 x64 with vs2008 (which has msvcm90.dll, msvcp90.dll and msvcr90.dll in C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\redist\\amd64\\Microsoft.VC90.CRT) 在Win 2K8 R2 x64的使用VS2008 开发 (其中有msvcm90.dll,msvcp90.dll和MSVCR90.DLL在C:\\ Program Files文件(x86)的\\微软的Visual Studio 9.0 \\ VC \\ REDIST \\ AMD64 \\ Microsoft.VC90.CRT)

and ran on win 2k3 SP2 x64, 在Win 2K3 SP2 64位,

but the msvcm80.dll, msvcp80.dll and msvcr80.dll are needed. 但是需要msvcm80.dll,msvcp80.dll和msvcr80.dll。

After install Microsoft Visual C++ 2005 SP1 Redistributable Package (x86) , the application can be installed and ran rightly. 安装Microsoft Visual C ++ 2005 SP1可再发行组件包(x86)后 ,可以正确安装和运行该应用程序。

对我来说,并排错误只是通过设置c / c ++ - > CodeGeneration-> RuntimeLibrary,使其成为MTD即多线程调试

We have really following problem here: the application executable references dlls using manifest machinery. 我们在这里确实存在以下问题:应用程序可执行文件使用清单机制引用dll。 In the deep past application authors just copied required dll's into system directories. 在过去的应用程序中,作者只需将所需的dll复制到系统目录中。 Unfortunately this caused so called "dll hell" problem when overwriting older dll versions by incompatible newer one could make applications stop working. 不幸的是,当通过不兼容的新版本覆盖旧的DLL版本时,这会导致所谓的“dll hell”问题,这会导致应用程序停止工作。 MS then came up with with versioning idea (winsxs). 然后,MS想出了版本化的想法(winsxs)。

Unfortunately this is quite complex machinery and it is definitely not a good idea to try manually installing dlls (assemblies) into the sxs folder. 不幸的是,这是非常复杂的机器,尝试手动将dll(程序集)安装到sxs文件夹中绝对不是一个好主意。 Installing so called "redistributable packages" is not a perfect solution either. 安装所谓的“可再发行软件包”也不是一个完美的解决方案。

Additionally, this cannot help when we want debug versions. 另外,当我们想要调试版本时,这无济于事。 As MS prohibits distribution of debug versions of supporting dlls, "redistributable packages" won't install them. 由于MS禁止分发支持dll的调试版本,“可再发行软件包”不会安装它们。 (Note that the assembly id depends on current subversion of VS2005 and is related to installed supporting libraries.) (请注意,程序集ID取决于VS2005的当前subversion,并且与已安装的支持库有关。)

Usually, the VS installer adds the required assemblies to the system, but after some time installation of updates or newer SDK's and tools may damage this correct state. 通常,VS安装程序会将所需的程序集添加到系统中,但在一段时间后安装更新或更新的SDK和工具可能会损坏此正确状态。

Let's assume we have this situation - our debug libraries are no longer integrated into system. 假设我们遇到这种情况 - 我们的调试库不再集成到系统中。 Suppose we have given workspace with project A and active debug configuration giving not working application. 假设我们已经为项目A和活动调试配置提供了工作空间,而不是工作应用程序。 We can then create installer project, say C in current workspace, add our application (or strictly, project with active configuration) to it. 然后我们可以在当前工作空间中创建安装程序项目,比如说C,添加我们的应用程序(或严格地说,使用活动配置的项目)。 Setup installer project to put our executable in some place (desktop is the right place regarding this situation) enable dependencies check and some other minor properties. 安装程序安装程序项目将我们的可执行文件放在某个地方(桌面是关于这种情况的正确位置)启用依赖项检查和一些其他次要属性。 Then build project C and run installer (or "install" from VS using context menu). 然后构建项目C并运行安装程序(或使用上下文菜单从VS“安装”)。 Now your application and other created with debug dll libraries start to work. 现在您的应用程序和使用debug dll库创建的其他应用程序开始工作。

Beware when you run installer with "remove" option you came to previous situation. 当你使用“删除”选项运行安装程序时要小心,你来到了以前的情况。 Here is good article related to distribution topic: http://blogs.msdn.com/b/vcblog/archive/2007/10/12/how-to-redistribute-the-visual-c-libraries-with-your-application.aspx . 这是与分发主题相关的好文章: http//blogs.msdn.com/b/vcblog/archive/2007/10/12/how-to-redistribute-the-visual-c-libraries-with-your-application .aspx

If you have some other applications and want to deploy them simply by copying, maybe on non development machine without installed VS, you may create dummy project together with appropriate configuration and installer for it . 如果您有其他一些应用程序,并希望仅通过复制来部署它们,可能在没有安装VS的非开发机器上,您可以创建虚拟项目以及适当的配置和安装程序。 You then install it once on each machine and then copy executable(s) you are working on. 然后在每台计算机上安装一次,然后复制您正在处理的可执行文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么MSVS 2010 MFC项目依赖于vcredist_x86.exe for MSVS 2008? - Why does MSVS 2010 MFC project depend on vcredist_x86.exe for MSVS 2008? 是否有小于 14 MB 的 Visual Studio 2015 C++ Redistributable (vcredist_x86.exe)? - Are there smaller Visual Studio 2015 C++ Redistributable (vcredist_x86.exe) than 14 MB? Api-ms-win-core-crt-l1-1-0.dll - Microsoft Visual C++ 2015 Redistributable(vc_redist.x64.exe 和 vcredist_x86.exe)无法安装 - Api-ms-win-core-crt-l1-1-0.dll - Microsoft Visual C++ 2015 Redistributable (vc_redist.x64.exe and vcredist_x86.exe) fails to install 当我在另一台计算机上执行(在计算机上编译的).exe时,出现此错误 - When I execute an .exe (compiled on my machine) on another computer it give me this error 同一台机器上的一个 exe 中的 CryptProtectData 和不同 exe 中的 CryptUnprotectData 和相同的用户凭据失败 - 错误代码 998 - CryptProtectData in one exe and CryptUnprotectData in different exe on same machine and same user credentials fails - Error code 998 从另一个exe运行一个exe - Run a Exe from another exe 如何在C ++中将一个.exe链接到另一个.exe - How to link one .exe to another .exe in C++ 为什么我不能运行带有特定文件名的exe? - Why can't I run an exe with a specific filename? 将一个 exe 嵌入另一个 exe 以构建单个 exe? - Embed one exe into another in order to build a single exe? qt exe文件无法运行 - qt exe file doesn't run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM