If I run an executable that throws an exception ( built in debug ), I will receive an error dialog, saying something like "Debug assertion failed" and then some information about the exception. While this happens, the program's execution is suspended, until I choose one of "Abort", "Retry" or "Ignore" options.
The thing is, I run a lot of applications from a script, and if one of them throws an exception, it pauses my script until it's handled.
Is there someway to disable this exception handling mechanism?
EDIT: I remember reading about a registry key, a while ago, which would disable the error messages from appearing. Does anyone know about it?
If you can modify the source, the abort behavior (called by assert) needs to be modified to suppress the abort/retry/ignore dialog.
On abort, a crashdump will still be produced (by default) so you won't lose what is important.
Additionally, you can adjust the assert behavior to write to stderr only. This is NOT required if the abort behavior is adequate for what you want. Note: the _Crtxxx calls are only active in debug builds (/Zi).
A minimal change to disable the abort/retry/ignore. Uncomment the _Crt calls and include crtdbg.h to also modify the assert behavior in debug mode builds.
#include <stdlib.h>
//#include <crtdbg.h>
int main(int argc,char **argv);
int main(int argc,char **argv)
{
// ON assert, write to stderr.
//_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
//_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
// Suppress the abort message
_set_abort_behavior( 0, _WRITE_ABORT_MSG);
abort();
return 0;
}
msdn assert mode
If you can modify the source of the application(s), have a look at the _CrtSetReportMode function, eg:
_CrtSetReportMode(_CRT_ASSERT, 0);
See msdn for more.
Can you build your executables as release? If I recall, that should stop the assertion errors from appearing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With