How can I disable the debug assertion dialog on Windows?

Check out _CrtSetReportHook():

http://msdn.microsoft.com/en-us/library/0yysf5e6.aspx

MSDN advertises this as a robust way for an application to handle CRT runtime failures like assertions. Presumably you can define a report hook that dumps your process:

How to create minidump for my process when it crashes?


This code will disable display of dialog. Instead, it will print an error in the output window, and stderr.

int main( int argc, char **argv )
{
     if( !IsDebuggerPresent() )
     {
          _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
          _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
     }

     ...
}

The same must be applied for _CRT_ERROR if you use Q_ASSERT from Qt library.