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

前端 未结 10 1507
情深已故
情深已故 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: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
    

提交回复
热议问题