3

When my Visual Studio 2008 C++ command-line application crashes, it sometimes produces this dialog.

CommandProcessor.exe has encountered a problem and needs to close.

We are sorry for the inconvenience. If you were in the middle of something, the information you were working on might be lost. For more informaiton about this error, click here.

I tried this in Release and in Debug mode.

(By the way, the debugger shows that this is a divide by zero error.)

If it is going to crash, I don't want this dialog, which blocks the application. How do I compile my application so that crashes do not produce the dialog?

2
  • 1
    how come a post-mortem dialog blocks an already-dead application? Commented Dec 2, 2009 at 12:18
  • Ironically that is true - the program is close to being finished but a message box is there. That's a huge problem for automated builds. Commented Dec 2, 2009 at 12:20

2 Answers 2

6

With /EHa option you can use catch(...) to catch all exceptions included structured exceptions and write a console message. You can also use VC++ - specific __try for structured exception handling instead, but that's a bit harder to code.

However this will not protect you against situations when terminate() is called by the C++ runtime - like when an exception escapes a destructor during stack unwinding - you will also have to change the terminate() handler by calling set_terminate().

Sign up to request clarification or add additional context in comments.

1 Comment

/EHa is best set through Project -> Properties -> Configuration properties -> C/C++ -> Code Generation -> Enable c++ exceptions. See stackoverflow.com/questions/623373/catching-exception-in-code
4

Read series of articles Exception Handling and Crash Reporting. It is possible to catch exception and process it as you wish (you can save crash dump for instance).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.