Why doesn’t Visual Studio 2010 break on an unhandled exception

debuggingexception handlingvisual studio 2010

When there is an exception thrown in my program, and it is unhandled, I expect the debugger to break in my program and show me what the problem is. This doesn't happen. Instead, my program simply exits, and debugging stops.

If I look at the debugging output, I can see my exception:

A first chance exception of type
'System.NullReferenceException'
occurred in System.dll

I am using Visual Studio 2010, Visual Basic, writing a simple WinForms app. The code doesn't matter in this case… it happens with any exception that I've seen so far.

I've read a lot online about doing to the Debug menu and clicking Exceptions and enabling "break on unhandled user exception", but I don't see this option. I think this advice is for VS2008, and is no longer applicable.

I should also note that I'm not running any unit tests. I have never set them up. However, I have read that perhaps the unit tester is swallowing my exceptions?

Please advise me on how to change the behavior of Visual Studio, so I can track down these unhandled exceptions.

Thank you for your time.

Best Answer

The item may not be in the menu, which you can fix by customising the menu and adding the item to the debug menu.

You should also be able to get to the exceptions menu using CTRL + ALT + E

You need to tick the box in the "Thrown" column for Common Language Runtime exceptions (CLR)