32

When coding in C# I like not to handle exceptions because it makes it easier to figure out where and why things went wrong. However, I can't give anyone a program that doesn't handle exceptions.

Can I somehow force Visual Studio to break on every exception, including those thrown inside try/catch blocks?

schlebe
  • 3,387
  • 5
  • 37
  • 50
hsprogrammer
  • 325
  • 1
  • 3
  • 4

2 Answers2

63

VS2015 and later: Go into Debug > Windows > Exception Settings and check the tick box against Common Language Runtime Exceptions (below the 'Break When Thrown' column header).

VS2013 and earlier: Go into Debug > Exceptions and check the Thrown box against Common Language Runtime Exceptions.

You may get a lot of noise this way though, as this will also break on exceptions thrown in libraries or inside the framework itself.

itowlson
  • 73,686
  • 17
  • 161
  • 157
  • 4
    It's a real shame this isn't the default behaviour. – stusmith Nov 08 '09 at 22:40
  • 5
    My favourite shortcut, 'ctrl+d e'. Keep in mind those things, they will save you lot of clicking. – nothrow Nov 08 '09 at 22:41
  • If I knew this would be so easy I would have asked this question sooner. This is going to save me a lot of time. Thank you! – hsprogrammer Nov 09 '09 at 00:12
  • the only problem is the 'false positives' or _noise_ , as someone else put it. sometimes those get me distracted from the real problem. there is no easy way to no if their harmless or not. – RyBolt Jan 20 '11 at 16:26
  • 1
    @itowlson Can we get an update? [tag:visual-studio-2015] – ricksmt Mar 16 '17 at 21:12
0

Update on Visual 2015 (not so easy :p)

  1. On the Tools menu, click Customize. The Customize dialog box appears.
  2. Click the Commands tab and, in the Menu bar list, click Debug.
  3. Click Add Command.
  4. In Categories in the Add Command dialog box, click Debug.
  5. In Commands, click Exceptions and then click OK.
  6. (Optional) You can click Move Down to adjust the position of the Exceptions command on the Debug menu.
  7. Click Close.

Source : https://msdn.microsoft.com/en-us/library/d14azbfh(v=vs.110).aspx

Chris R.
  • 562
  • 7
  • 31