What is a first chance exception anyway?

This kb article is the best explanation of what a first chance exception is I have ever read (http://support.microsoft.com/kb/105675):

“However, if the application is being debugged, the debugger sees all exceptions before the program does. This is the distinction between the first and second chance exception: the debugger gets the first chance to see the exception (hence the name). If the debugger allows the program execution to continue and does not handle the exception, the program will see the exception as usual. If the program does not handle the exception, the debugger gets a second chance to see the exception. In this latter case, the program normally would crash if the debugger were not present.”

How do I catch first chance exceptions?

In visual studio under the debug > exceptions menu and tick the boxes shown in red:

No comments:

Post a Comment