13

To toggle break on all exceptions right now, I have to:

  1. Debug->Exceptions
  2. Click in the Thrown column next to "Common Language Runtime Eceptions"
  3. OK

enter image description here

Normally I want to stop on all exceptions, but when working in code that uses exceptions in mainline cases, I need to disable that behavior. Having a keystroke would be nice.

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168
  • 1
    I suppose you could record a macro to do this and bind it to a key combo... – JerKimball Apr 03 '13 at 06:20
  • @JerKimball: A recorded macro contains a single line `DTE.ExecuteCommand("Debug.Exceptions")` - and will indeed only show the dialog. – Martin Apr 03 '13 at 07:30
  • 1
    It's easy to bind a key to open the dialog (and I already have such a binding, by default). But I want a key to toggle the break-on-all. – Jay Bazuzi Apr 03 '13 at 07:39
  • Related: [Can I adjust the visual studio "Break when an exception is thrown" options programatically?](http://stackoverflow.com/q/832217) – Cody Gray - on strike Apr 03 '13 at 22:16
  • With Cody Grays hint: Dim debugger As Debugger3 = DTE.Debugger Dim exceptionGroup As ExceptionSettings = debugger.ExceptionGroups.Item("Common Language Runtime Exceptions") For Each ex As ExceptionSetting In exceptionGroup exceptionGroup.SetBreakWhenThrown(True, ex) Next But this is terribly slow. (Sorry, don't know how to include linebreaks in a comment.) – Martin Apr 04 '13 at 08:41
  • @CodyGray: The macros system is gone from VS2012, but the automation model is still there. You can reach it from the PowerShell-based Package Manager Console (e.g. `$dte.Debugger`) but I'm not sure how to get the `ExceptionGroups` from it. – Jay Bazuzi Apr 05 '13 at 05:00
  • 1
    Nuts! I didn't realize this question was about VS 2012. I haven't switched yet, the UI is intolerable for me. Well, that's why I didn't vote to close as a dupe. :-) – Cody Gray - on strike Apr 05 '13 at 05:08
  • See also this [Question](https://stackoverflow.com/questions/62264331/is-there-a-keyboard-shortcut-to-enable-disable-common-language-runtime-exceptio)/[Answer](https://stackoverflow.com/a/70267307/9300908) using Visual Commander for later versions of Visual Studio – pigeon Dec 07 '21 at 21:56

1 Answers1

6

There is no built-in way to do this.
However, unless you are using Visual Studio Express you can try this Extension: Exception Breaker, it works for me.

What this extension does is provide a toolbar-button that basically toggles the checkbox you showed in your picture. And you can assign a keystroke to it like any other toolbar-button.

void
  • 881
  • 3
  • 20
  • 27