This application has requested the runtime to terminate it in an unusual way

Posted on 2010-08-23
Last Modified: 2012-05-10
I'm getting this error when I'm trying to run my application without the debugger. The Microsoft help site says this:

This problem may occur when you use the /GR and the /MD compiler switches, and the version of the Msvcrt.dll file and of the Msvcirt.dll file is 7.0.x.

There is a hotfix for Windows XP but there's no solution for anything else (I use Windows 7). Also, I can't just ship a hotfix along with it.
I don't really know much about compiler switches, how do I compile this program and have this error go away?

I'm using Visual Studio 2008, this is my command line:

/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

Open in new window

Thanks in advance.
Question by:Snapples
LVL 40

Expert Comment

ID: 33503517
>> This problem may occur when you use the /GR and the /MD compiler switches, and the version of the Msvcrt.dll file and of the Msvcirt.dll file is 7.0.x.

I wouldn't read too much into that... there are plenty of reasons why your code could be generating this error. The main one is that the code has thrown an exception and it has not been caught or handled.

The following tiny bit of code demonstrates this.
int main()


	throw 0;


Open in new window


Author Comment

ID: 33503613
Well, I have try catch blocks everywhere in my program, also at the start, but I get the runtime error before it even gets there.
LVL 86

Accepted Solution

jkr earned 500 total points
ID: 33503652
Since you mention explicitly "when I'm trying to run my application without the debugger" the reason is most likely an uninitialized variable, since when running under the VS debugger, all variables are explicitly initialized. I'd start double checking that.
LVL 40

Expert Comment

ID: 33504135
>> Well, I have try catch blocks everywhere in my program

Well that's not the only reason you might get the error - it was more an example of the fact that the MSDN article is probably a red-herring. Also, where you say you have catch blocks - what exactly are you catching?

You should also check what jkr suggests. Also, newer versions of Visual Studio instrument code with buffer overflow checks and can be the cause of such errors.

Out of interest are you running release or debug versions of the code? How do they both run in the debugger? How do they both run if you have no debugger attached?
LVL 33

Expert Comment

ID: 33504430
Just a moment. The command line you posted generates the debug version. How I understand you have problem with the release build. If you have a mistake in the project settings, in the release configuration, the application will crash.

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now