如何快速告诉Visual Studio停止每个异常

时间:2011-10-27 21:39:04

标签: visual-studio-2010 exception

目前,如果我想告诉Visual Studio 2010停止异常,我必须转到Debug / Exceptions ...菜单(或Ctrl + Alt + E)并单击CLR Exceptions下的Thrown复选框。这是一个耗时的过程,特别是如果我需要定期切换这些过程。

是否有更快捷的方法来切换此功能?也许用键盘快捷键。

1 个答案:

答案 0 :(得分:1)

使用类似的东西:

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

它将成功检查“例外”对话框中的顶级复选框。