Visual c++ /Studio:应用程序配置不正确?

时间:2021-08-05 21:02:56

My C(++) program, written and compiled using Visual C(++)/Visual Studio, runs fine on my own machine, but refuses to run on another machine. The error message I get is "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."

我的C(++)程序使用Visual C(++)/Visual Studio编写和编译,在我自己的机器上运行良好,但拒绝在另一台机器上运行。我得到的错误消息是“由于应用程序配置不正确,所以该应用程序未能启动。”重新安装应用程序可以解决这个问题。

10 个解决方案

#1


5  

If you write a C++ program, it links dynamically to the C Runtime Library, or CRT for short. This library contains your printf, your malloc, your strtok, etcetera. The library is contained in the file called MSVCR80.DLL. This file is not by default installed on a Windows system, hence the application cannot run.

如果您编写一个c++程序,它会动态地链接到C运行时库,或者简称为CRT。这个库包含你的printf、malloc、strtok等等。库包含在名为msvcr . dll的文件中。这个文件不是默认安装在Windows系统上的,因此应用程序不能运行。

The solution? Either install the DLL on the target machine through VCREDIST.EXE (the Visual C++ Redistributable Package), or link to the CRT statically (plug the actual code for the used functions straight into your EXE).

解决方案?可以通过VCREDIST在目标机器上安装DLL。EXE (Visual c++可重分发包),或静态地链接到CRT(将使用函数的实际代码直接插入到EXE中)。

Distributing and installing VCREDIST along with a simple application is a pain in the arse, so I went for the second option: static linking. It's really easy: go to your project's properties, unfold C/C++, click Code Generation, and set the Runtime Library to one of the non-DLL options. That's all there is to it.

分发和安装VCREDIST和一个简单的应用程序在arse中是一种痛苦,所以我选择了第二个选项:静态链接。这很简单:进入项目的属性,展开C/ c++,单击代码生成,并将运行时库设置为一个非dll选项。这就是一切。

#2


5  

The problem here is a missing DLL dependency, such as the CRT (C Runtime Library). A good tool for diagnosing this sort of problem is Dependency Walker (depends.exe), which you can find here:

这里的问题是缺少DLL依赖,比如CRT (C运行时库)。诊断这类问题的一个好工具是依赖项Walker(依赖性.exe),您可以在这里找到:

http://www.dependencywalker.com/

http://www.dependencywalker.com/

You would run this program on the computer that generates the error message you posted, and use it to open the exe that's generating this error. Dependency Walker will quickly and graphically indicate any DLLs that are required but not available on the machine.

您将在生成您发布的错误消息的计算机上运行此程序,并使用它打开产生此错误的exe。依赖项Walker将快速和图形化地指示任何需要但不可在机器上可用的dll。

#3


1  

Chances are high that you miss the runtime libraries of Visual Studio (CRT amongst others), you can either get rid of those dependencies (link statically) or install the VC redist packages on the target computer.

您很可能会错过Visual Studio的运行时库(CRT和其他库),您可以删除这些依赖项(静态链接),或者在目标计算机上安装VC重发包。

Depending on the Visual C++ version you use, you have to install different packages :

根据您使用的Visual c++版本,您必须安装不同的包:

Visual C++ 2005

Visual c++ 2005

Visual C++ 2005 SP1

Visual c++ 2005 SP1

Visual C++ 2008

Visual c++ 2008

Warning : those packages only contain release versions of the libraries, if you want to be able to distribute debug builds of your application you'll have to take care of the required DLL yourself.

警告:这些包只包含库的发布版本,如果您想要分发应用程序的调试构建,您必须自己处理所需的DLL。

#4


1  

It is much the simplest to link to the runtime statically.

最简单的方法是静态地链接到运行时。

c++ -> Code Generation -> Runtime Library and select "multi-threaded /MT"

c++ ->代码生成->运行时库,选择“多线程/MT”

However, this does make your executable a couple hundred KByte larger. This might be a problem if you are installing a large number of small programs, since each will be burdened by its very own copy of the runtime. The answer is to create an installer.

然而,这确实使您的可执行文件变得大了几百kb。如果您正在安装大量的小程序,这可能是一个问题,因为每个程序都有自己的运行时副本。答案是创建一个安装程序。

New project -> "setup and deployment" -> "setup project"

新项目->“安装和部署”->“安装项目”

Load the output from your application projects ( defined using the DLL version of the runtime ) into the installer project and build it. The dependency on the runtime DLL will be noticed, included in the installer package, and neatly and unobtrusively installed in the correct place on the target machine.

将应用程序项目的输出(使用运行时的DLL版本定义)加载到安装程序项目中并构建它。对运行时DLL的依赖关系将被注意到,包括在安装程序包中,并且整齐地、不引人注目地安装在目标计算机的正确位置。

#5


1  

The correct VC Redist package for you is part of your Visual Studio installation. For VC 8, you can find it here:

正确的VC重拨包是Visual Studio安装的一部分。对于VC 8,你可以在这里找到:

\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86

#6


1  

POSSIBLE SOLUTION........

可能的解决方案........

EDIT: (removed most of my post) Long story short, I was having similar problems, getting the "Application Configuration Incorrect" messages, etc etc. Depends.exe was only finding ieshims.dll and wer.dll as possible issues, but this is not the problem. I ended up using the Multithreaded (/mt) compile option. What HAS worked though, as a workable solution, is making an installer with InstallShield. I've selected several merge modules in installshield builder and this seems to have fixed my problem. The modules selected were: VC++ 9.0 CRT, VC++ 9.0 DEBUG CRT, and the CRT WinSXS MSM merge module. I'm pretty sure its the WinSXS merge module that has fixed it.

编辑:(删除了我的大部分文章)长话短说,我遇到了类似的问题,收到“应用程序配置不正确”的消息等等,依情况而定。exe只发现了ieshim。dll和回答。dll可能存在的问题,但这不是问题所在。最后我使用了多线程(/mt)编译选项。不过,作为一个可行的解决方案,使用InstallShield制作安装程序是可行的。我在installshield builder中选择了几个合并模块,这似乎解决了我的问题。所选模块为:vc++ 9.0 CRT, vc++ 9.0 DEBUG CRT, CRT WinSXS MSM合并模块。我很确定它的WinSXS合并模块已经修复了它。

DEBUG CRT: I noticed somewhere that (no matter how hard I tried, and obviously failed thus far), my Release version still depended on the DEBUG CRT. If this is still the case, the InstallShield merge module has now placed the DEBUG CRT folder in my WinSXS folder :) Being somewhat of a novice with VC++ I assume that this would normally be used to distribute debug versions of your programs to other people. To test if this is what fixed my problem I removed the DEBUG CRT folder from the WinSXS folder and the application still worked. (Unless something is still running in the background etc etc - I'm not that into it)

调试CRT:我注意到(无论我怎么努力,显然到目前为止都失败了),我的发布版本仍然依赖于调试CRT。如果仍然是这种情况,那么InstallShield merge module现在已经将DEBUG CRT文件夹放在我的WinSXS文件夹:)中。为了测试这是否解决了我的问题,我从WinSXS文件夹中删除了DEBUG CRT文件夹,应用程序仍然正常工作。(除非有什么东西还在后台运行等等——我不是很喜欢)

Anyway, this has got things working for me on an XP SP3 fully updated machine, and also on a VMWare XP SP3 machine with the bare bones (.net 3.5 and VC++ 2008 RTM basically) - and also on a mate's XP machine where it previously wasn't working.

无论如何,这让我在XP SP3完全更新的机器上,以及在VMWare XP SP3的机器上(基本上是。net 3.5和vc++ 2008 RTM),以及在mate的XP机器上,它以前不工作。

So give these things a try, you might have some luck.

所以尝试一下这些东西,你可能会有一些运气。

#7


1  

First thing you must use

首先你必须使用

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1

or add _BIND_TO_CURRENT_VCLIBS_VERSION=1 to the preprocessor directives.

或者向预处理程序指令添加_BIND_TO_CURRENT_VCLIBS_VERSION=1。

The problem is related to binding and the manifest types, you can find more http://www.nuonsoft.com/blog/2008/10/29/binding-to-the-most-recent-visual-studio-libraries/

问题与绑定和清单类型有关,您可以找到http://www.nuonsoft.com/blog/2008/10/29/binding-to- The -recent- visualstudio -libraries/

By doing this your application will run with a larger range of runtime libraries versions.

通过这样做,应用程序将运行在更大范围的运行时库版本中。

#8


0  

Often times this error is the result of attempting to run the debug version of an application that uses .NET. Since the .NET redistributable package doesn't include the debug versions of the dlls that are installed with Visual Studio, your application will often get this error when running it on any other machine that doesn't have Visual Studio installed. If you haven't already, try building a release version of your application and see if that works.

通常,这个错误是尝试运行使用。net的应用程序的调试版本的结果。由于. net redistributable包不包括与Visual Studio一起安装的dll的调试版本,所以在没有安装Visual Studio的任何其他机器上运行时,应用程序通常会遇到这个错误。如果您还没有构建应用程序的发布版本,请尝试构建该版本,看看它是否有效。

#9


0  

Note also - that if you change to static runtime, you will have to do the same for MFC if your app uses MFC. Those settings are in properties->Configuration/General

还要注意的是,如果您的应用程序使用MFC,那么如果您更改为静态运行时,您将不得不对MFC执行相同的操作。这些设置在属性->配置/一般。

#10


0  

I ran into this problem and was able to fix it very simply.

我遇到了这个问题,能够很简单地解决它。

Visual studio gives you the option (on by default) to build a manifest for each build.

Visual studio为您提供了为每个构建构建构建一个清单的选项(默认为on)。

The manifest was put in the release folder, but it was a different release folder than the exe.

清单被放在发布文件夹中,但它与exe是不同的发布文件夹。

Even when using the setup utilities it was not packaged.

即使在使用安装工具时,它也没有被打包。

You should look for a file names something like myprogram.exe.indermediate.manifest

您应该查找文件名,比如myprogram.exe.indermediat .manifest

If this is in the same folder as the exe (and you have all the dlls) it should run

如果它与exe(并且您有所有dll)位于同一个文件夹中,那么它应该运行

#1


5  

If you write a C++ program, it links dynamically to the C Runtime Library, or CRT for short. This library contains your printf, your malloc, your strtok, etcetera. The library is contained in the file called MSVCR80.DLL. This file is not by default installed on a Windows system, hence the application cannot run.

如果您编写一个c++程序,它会动态地链接到C运行时库,或者简称为CRT。这个库包含你的printf、malloc、strtok等等。库包含在名为msvcr . dll的文件中。这个文件不是默认安装在Windows系统上的,因此应用程序不能运行。

The solution? Either install the DLL on the target machine through VCREDIST.EXE (the Visual C++ Redistributable Package), or link to the CRT statically (plug the actual code for the used functions straight into your EXE).

解决方案?可以通过VCREDIST在目标机器上安装DLL。EXE (Visual c++可重分发包),或静态地链接到CRT(将使用函数的实际代码直接插入到EXE中)。

Distributing and installing VCREDIST along with a simple application is a pain in the arse, so I went for the second option: static linking. It's really easy: go to your project's properties, unfold C/C++, click Code Generation, and set the Runtime Library to one of the non-DLL options. That's all there is to it.

分发和安装VCREDIST和一个简单的应用程序在arse中是一种痛苦,所以我选择了第二个选项:静态链接。这很简单:进入项目的属性,展开C/ c++,单击代码生成,并将运行时库设置为一个非dll选项。这就是一切。

#2


5  

The problem here is a missing DLL dependency, such as the CRT (C Runtime Library). A good tool for diagnosing this sort of problem is Dependency Walker (depends.exe), which you can find here:

这里的问题是缺少DLL依赖,比如CRT (C运行时库)。诊断这类问题的一个好工具是依赖项Walker(依赖性.exe),您可以在这里找到:

http://www.dependencywalker.com/

http://www.dependencywalker.com/

You would run this program on the computer that generates the error message you posted, and use it to open the exe that's generating this error. Dependency Walker will quickly and graphically indicate any DLLs that are required but not available on the machine.

您将在生成您发布的错误消息的计算机上运行此程序,并使用它打开产生此错误的exe。依赖项Walker将快速和图形化地指示任何需要但不可在机器上可用的dll。

#3


1  

Chances are high that you miss the runtime libraries of Visual Studio (CRT amongst others), you can either get rid of those dependencies (link statically) or install the VC redist packages on the target computer.

您很可能会错过Visual Studio的运行时库(CRT和其他库),您可以删除这些依赖项(静态链接),或者在目标计算机上安装VC重发包。

Depending on the Visual C++ version you use, you have to install different packages :

根据您使用的Visual c++版本,您必须安装不同的包:

Visual C++ 2005

Visual c++ 2005

Visual C++ 2005 SP1

Visual c++ 2005 SP1

Visual C++ 2008

Visual c++ 2008

Warning : those packages only contain release versions of the libraries, if you want to be able to distribute debug builds of your application you'll have to take care of the required DLL yourself.

警告:这些包只包含库的发布版本,如果您想要分发应用程序的调试构建,您必须自己处理所需的DLL。

#4


1  

It is much the simplest to link to the runtime statically.

最简单的方法是静态地链接到运行时。

c++ -> Code Generation -> Runtime Library and select "multi-threaded /MT"

c++ ->代码生成->运行时库,选择“多线程/MT”

However, this does make your executable a couple hundred KByte larger. This might be a problem if you are installing a large number of small programs, since each will be burdened by its very own copy of the runtime. The answer is to create an installer.

然而,这确实使您的可执行文件变得大了几百kb。如果您正在安装大量的小程序,这可能是一个问题,因为每个程序都有自己的运行时副本。答案是创建一个安装程序。

New project -> "setup and deployment" -> "setup project"

新项目->“安装和部署”->“安装项目”

Load the output from your application projects ( defined using the DLL version of the runtime ) into the installer project and build it. The dependency on the runtime DLL will be noticed, included in the installer package, and neatly and unobtrusively installed in the correct place on the target machine.

将应用程序项目的输出(使用运行时的DLL版本定义)加载到安装程序项目中并构建它。对运行时DLL的依赖关系将被注意到,包括在安装程序包中,并且整齐地、不引人注目地安装在目标计算机的正确位置。

#5


1  

The correct VC Redist package for you is part of your Visual Studio installation. For VC 8, you can find it here:

正确的VC重拨包是Visual Studio安装的一部分。对于VC 8,你可以在这里找到:

\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86

#6


1  

POSSIBLE SOLUTION........

可能的解决方案........

EDIT: (removed most of my post) Long story short, I was having similar problems, getting the "Application Configuration Incorrect" messages, etc etc. Depends.exe was only finding ieshims.dll and wer.dll as possible issues, but this is not the problem. I ended up using the Multithreaded (/mt) compile option. What HAS worked though, as a workable solution, is making an installer with InstallShield. I've selected several merge modules in installshield builder and this seems to have fixed my problem. The modules selected were: VC++ 9.0 CRT, VC++ 9.0 DEBUG CRT, and the CRT WinSXS MSM merge module. I'm pretty sure its the WinSXS merge module that has fixed it.

编辑:(删除了我的大部分文章)长话短说,我遇到了类似的问题,收到“应用程序配置不正确”的消息等等,依情况而定。exe只发现了ieshim。dll和回答。dll可能存在的问题,但这不是问题所在。最后我使用了多线程(/mt)编译选项。不过,作为一个可行的解决方案,使用InstallShield制作安装程序是可行的。我在installshield builder中选择了几个合并模块,这似乎解决了我的问题。所选模块为:vc++ 9.0 CRT, vc++ 9.0 DEBUG CRT, CRT WinSXS MSM合并模块。我很确定它的WinSXS合并模块已经修复了它。

DEBUG CRT: I noticed somewhere that (no matter how hard I tried, and obviously failed thus far), my Release version still depended on the DEBUG CRT. If this is still the case, the InstallShield merge module has now placed the DEBUG CRT folder in my WinSXS folder :) Being somewhat of a novice with VC++ I assume that this would normally be used to distribute debug versions of your programs to other people. To test if this is what fixed my problem I removed the DEBUG CRT folder from the WinSXS folder and the application still worked. (Unless something is still running in the background etc etc - I'm not that into it)

调试CRT:我注意到(无论我怎么努力,显然到目前为止都失败了),我的发布版本仍然依赖于调试CRT。如果仍然是这种情况,那么InstallShield merge module现在已经将DEBUG CRT文件夹放在我的WinSXS文件夹:)中。为了测试这是否解决了我的问题,我从WinSXS文件夹中删除了DEBUG CRT文件夹,应用程序仍然正常工作。(除非有什么东西还在后台运行等等——我不是很喜欢)

Anyway, this has got things working for me on an XP SP3 fully updated machine, and also on a VMWare XP SP3 machine with the bare bones (.net 3.5 and VC++ 2008 RTM basically) - and also on a mate's XP machine where it previously wasn't working.

无论如何,这让我在XP SP3完全更新的机器上,以及在VMWare XP SP3的机器上(基本上是。net 3.5和vc++ 2008 RTM),以及在mate的XP机器上,它以前不工作。

So give these things a try, you might have some luck.

所以尝试一下这些东西,你可能会有一些运气。

#7


1  

First thing you must use

首先你必须使用

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1

or add _BIND_TO_CURRENT_VCLIBS_VERSION=1 to the preprocessor directives.

或者向预处理程序指令添加_BIND_TO_CURRENT_VCLIBS_VERSION=1。

The problem is related to binding and the manifest types, you can find more http://www.nuonsoft.com/blog/2008/10/29/binding-to-the-most-recent-visual-studio-libraries/

问题与绑定和清单类型有关,您可以找到http://www.nuonsoft.com/blog/2008/10/29/binding-to- The -recent- visualstudio -libraries/

By doing this your application will run with a larger range of runtime libraries versions.

通过这样做,应用程序将运行在更大范围的运行时库版本中。

#8


0  

Often times this error is the result of attempting to run the debug version of an application that uses .NET. Since the .NET redistributable package doesn't include the debug versions of the dlls that are installed with Visual Studio, your application will often get this error when running it on any other machine that doesn't have Visual Studio installed. If you haven't already, try building a release version of your application and see if that works.

通常,这个错误是尝试运行使用。net的应用程序的调试版本的结果。由于. net redistributable包不包括与Visual Studio一起安装的dll的调试版本,所以在没有安装Visual Studio的任何其他机器上运行时,应用程序通常会遇到这个错误。如果您还没有构建应用程序的发布版本,请尝试构建该版本,看看它是否有效。

#9


0  

Note also - that if you change to static runtime, you will have to do the same for MFC if your app uses MFC. Those settings are in properties->Configuration/General

还要注意的是,如果您的应用程序使用MFC,那么如果您更改为静态运行时,您将不得不对MFC执行相同的操作。这些设置在属性->配置/一般。

#10


0  

I ran into this problem and was able to fix it very simply.

我遇到了这个问题,能够很简单地解决它。

Visual studio gives you the option (on by default) to build a manifest for each build.

Visual studio为您提供了为每个构建构建构建一个清单的选项(默认为on)。

The manifest was put in the release folder, but it was a different release folder than the exe.

清单被放在发布文件夹中,但它与exe是不同的发布文件夹。

Even when using the setup utilities it was not packaged.

即使在使用安装工具时,它也没有被打包。

You should look for a file names something like myprogram.exe.indermediate.manifest

您应该查找文件名,比如myprogram.exe.indermediat .manifest

If this is in the same folder as the exe (and you have all the dlls) it should run

如果它与exe(并且您有所有dll)位于同一个文件夹中,那么它应该运行