【问题标题】:How to quickly tell Visual Studio to stop on every exception如何快速告诉 Visual Studio 停止每个异常
【发布时间】:2011-12-16 21:22:10
【问题描述】:

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

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

【问题讨论】:

  • @Valamas 我看到了这个问题,它很相似,但答案涉及创建宏,其实例化是非常耗时的。我会以一种放缓换另一种。

标签: visual-studio-2010 exception


【解决方案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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多