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)?


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 Microsoft Visual Studio invention.


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


I just started using the debugger and ran into this. In my research, I found the MSDN blog post What is a First Chance Exception? that cleared it up for me.

The big takeaways from the blog post for me are that it refers to notification to the debugger, and not something my code would necessarily need to handle, and most importantly,

"First chance exception messages most often do not mean there is a problem in the code."