Breakpoint on an exception in visual studio
Solution 1
I haven't used Visual Studio for 2 years, but from memory:
Ctrl + Alt + E
Will bring exception management screen, make sure to check break on all exceptions, a must have imho :)
EDIT : My memory not that bad :) Just check Thrown
on Common Language Runtime Exceptions
if your are using .NET (CLR = .NET)
EDIT 2 : By the way, since exceptions are generally a bad coding practice and should be avoided as possible, i suggest to let that option enabled all the time. If some exceptions just can't be avoided (because of someone else, of course :D) just uncheck its type or ancestor in the exception type tree.
Solution 2
The exact visual studio command name is Debug.Exceptions
Main Menu > Debug > Exceptions (when solution is open)
Solution 3
Also, make sure you're running in debug mode and that debugging is enabled in the project properties or else all the breakpoints in the world will count for nothing.
(Depending on your environment you can also click on the margin outside the code source to insert a breakpoint via mouse action)
Related videos on Youtube
Comments
-
Himadri Choudhury about 4 years
How do I set a breakpoint on an exception? Ideally I want to be able to see the call stack and local variables from the code that threw the exception.
-
abatishchev about 13 yearsExceptions ARE NOT bad coding practice
-
Vincent Guerci about 13 years@abatishchev Added generally to my answer, seriously, I've seen enough atrocities implicating bad exception use. :)
-
kevinthompson almost 8 yearsIn Visual Studio 2015 it's Main Menu > Debug > Windows > Exception Settings.