views:

712

answers:

3

What exactly is a first chance exception? How and where does it originate in a .Net program? And why is it called by that peculiar name (what 'chance' are we talking about)?

+4  A: 

It's a debugging concept. Basically exceptions are thrown to the debugger first and then to the actual program where if it isn't handled it gets thrown to the debugger a second time, giving you a chance to do something with it in your IDE before and after the application itself. This appears to be a MSVS invention.

(edit: slightly wrong about the meaning of second chance it seems, edited accordingly)

annakata
+2  A: 

See this explanation.

Frederick
+3  A: 

First chance exception notifications are raised when an exception is thrown. Second chance notifications are when it is not caught. (Chance - as in opportunity to break into the code in the debugger).

First and second chance exception handling

Ian G