4

Currently if I want to tell Visual Studio 2010 to stop on an exception, I have to go to the Debug/Exceptions... menu (or Ctrl+Alt+E) and click on the Thrown checkbox under CLR Exceptions. This is a time-consuming process, particularly if I need to toggle these at some regularity.

Is there a faster way to toggle this feature? Perhaps with a keyboard shortcut key.

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • Possible dup: http://stackoverflow.com/questions/958011/toggle-break-when-an-exception-is-thrown-using-macro-or-keyboard-shortcut – Valamas Oct 27 '11 at 21:41
  • @Valamas I saw that question and it is similar, but the answer involved creating macros, the instantiation of which is crazy time-consuming as is. I would be trading one slowdown for another. – AngryHacker Oct 27 '11 at 21:44

1 Answers1

1

Use something like this:

Dim dbg As EnvDTE90.Debugger3 = DTE.Debugger
Dim exSettings As EnvDTE90.ExceptionSettings = dbg.ExceptionGroups.Item("Common Language Runtime Exceptions")
Dim exSetting As EnvDTE90.ExceptionSetting
Try
    exSetting = exSettings.Item("Common Language Runtime Exceptions")
Catch ex As COMException
    If ex.ErrorCode = -2147352565 Then
        exSetting = exSettings.NewException("Common Language Runtime Exceptions", 0)
    End If
End Try

If exSetting.BreakWhenThrown Then
    exSettings.SetBreakWhenThrown(False, exSetting)
Else
    exSettings.SetBreakWhenThrown(True, exSetting)
End If

It will successfully check the top-level check-box in the Exceptions dialog.

Adrian
  • 671
  • 4
  • 17
  • 37