Toggle “Break when an exception is thrown.” using macro or keyboard shortcut

前端 未结 10 1465
情深已故
情深已故 2020-11-29 23:51

Edit: Visual Studio 2015\'s new exception window is so much faster than the old dialog that I no longer care as much about using a keyboard shortcut for i

相关标签:
10条回答
  • 2020-11-30 00:25

    I have created a free Visual Studio extension that can do that reliably: Exception Breaker.
    It uses undocumented IDebugSession2.SetException call that is very fast: all exceptions are set/unset in 20 to 60 milliseconds.

    0 讨论(0)
  • 2020-11-30 00:29

    Just offering some info I found on this (here) as I was scouring the net in my futile attempt to help...

    Someone else posed this same question and it was responded to by Gary Chang from MS Support, here's the quoted response:

    I am afraid the Macro code cannot manipulate the operations on the Exceptions dialog box...

    It's important to note that this posting is from December of 2005 so this response may no longer be accurate; either way, thought I'd throw it out there.

    0 讨论(0)
  • 2020-11-30 00:31

    The suggestion of setting the special ExceptionSetting for the group does indeed toggle the state of the top-level checkbox. However, it doesn't seem to toggle the individual Exceptions below it in the tree, and moreover, my process does not stop when such exceptions are thrown as it does if I manually check the top-level checkbox. Do you see different behavior?

    0 讨论(0)
  • 2020-11-30 00:32

    Here's Bryce Kahle's very useful macro blindly updated to run in VS2010:

    Sub ToggleExceptions()
        Dim dbg As EnvDTE100.Debugger5 = DTE.Debugger
        Dim exSettings As ExceptionSettings = dbg.ExceptionGroups.Item("Common Language Runtime Exceptions")
        Dim exSetting As 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
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题