I know this post has been around for a while, but, I just happened upon it searching for something else. I’m happy to say that what user ‘abelenky’ asks is possible if the filter exists in a separate dll. You can debug an unhandled exception filter using a debugger. I’ve done it, and, here’s how:
- The exception filter must exist in a separate dll. You’ll see why later.
You’ll need to add some code to the filter that displays a message box. I use the following code:
#ifdef _DEBUG
AfxMessageBox (_T("At this time, you must attach the debugger to this process in order to debug the filter code."));
#endif
The #ifdef is important because you don’t want the code executing in a Release build. I placed the above code at the very top of my filter.
To debug the filter:
- Build a Release version of your application in Visual Studio
(instance #1).
- Build a Debug version of your filter in a second instance of VS (#2).
- Copy the Debug version of the filter to the Release folder of your
application.
- Start your Release application from the Debug menu “without
debugging”.
- Cause a crash in your application.
- When the debug message box (above) appears, change to the second instance (#2) of Visual Studio.
- In the #2 instance, open the filter project in Debug (if it isn't open) and attach the
debugger to your Application instance.
- Set a breakpoint in your filter code after the message box displays.
- Close the message box and your breakpoint should be hit.
- Continue to debug your code.