Monday, November 28, 2011

Disable Assert dialogs during windows native code debugging

Debugging native code on windows sometimes throws the assert dialog boxes. In some cases you may not be interested in those asserts or as in my case those boxes may be blocking your UI debugging. You can comment/remove all your assert statements from your source. But in some cases the asserts are from the code which you dont have access, or may be you dont want to remove them for some reason.

Here is what I did to stop those assert dialog boxes from coming up.

Add the following code in your DllMain
#ifdef _DEBUG
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
#endif
You have to include...
#ifdef _DEBUG
#include "Crtdbg.h"
#endif

For more info, check this MSDN Link...
http://msdn.microsoft.com/en-us/library/1y71x448%28v=vs.80%29.aspx

No comments:

Post a Comment