How to make visual studio break only on unhandled exceptions?
Solution 1
Make sure you have Just My Code Enabled
by going into Tools-->Options-->Debugger-->General--> Enable Just My Code. This will change your Debug--> Exceptions Dialog Box to show a CheckBox for User-unhandled Errors.
Solution 2
I cannot find the dialogue in the accepted answer.
In my experience, in Exception Settings, if you hit "Restore the list to default settings", it will not break on exceptions you handled. If you checked a particular exception in Exception Settings, then it will break regardless of whether you handles this exception in your code or not.
Solution 3
For a more updated answer:
When you go to the exception settings right click on the exception type you want, which for C# would probably be Common Language Runtime Exceptions, and enable the "Continue When Unhandled in User Code" setting.
For me this seemed to not break on exceptions that were handled in a try catch or otherwise, but it did break when an unhandled exception occurred. The naming of the option makes it feel a bit iffy but it seems to work exactly as you and I hoped now.
Exception settings
Enable the required setting
Comments
-
Brandon Moore almost 2 years
On my other machines, Visual Studio always broke on errors when there was not a try/catch to handle them, but if there was a try/catch then it didn't break.
For some reason, on this laptop, it doesn't work that way. It didn't break at all at first, but then I found out how to set it to break by going to debug/exceptions. However, configuring it to break there causes it to always break on exceptions even if there is a try/catch block.
How do I make it work like I'm used to?
-
Mark Hall almost 12 years@BrandonMoore no problem, they kind of went out of the way to hide it.
-
Brandon Moore almost 12 yearsAnd misleading... I'm guessing that most likely I saw that at some point and was like "What? No I want to 'limit' it to just my code".
-
jeromej over 5 years
Debug > Options
is a better option since searching for debug inTools > Options
does show the right window but only with entries containing the word "debug" unless you clear your search. -
jeromej over 5 yearsAnswer is outdated. :(
-
Daniel-Dane over 2 yearsRemember to enable Just My Code.
-
Shameer over 2 years"right click on the exception type you want, which for C# would probably be Common Language Runtime Exceptions, and enable the "Continue When Unhandled in User Code" setting." I can't find this setting...