visual-studio - 使用宏或键盘快捷键切换 "Break when an exception is thrown."

标签 visual-studio exception ide visual-studio-macros

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 it.

是否有宏或键盘快捷键可以在不使用 GUI 的情况下切换“抛出异常时中断”?

使用 ctrl+alt+e 打开对话框并选中“公共(public)语言运行时异常”“抛出”框,然后单击“确定”非常简单,但这是我经常做的事情。我宁愿有一个键盘快捷键。

这个问题是重复的 Any have a Visual Studio shortcut/macro for toggling break on handled/unhandled exceptions?

但是,发帖者接受的答案实际上不起作用,而我真的很想要一个确实有效的答案。

重复问题中的答案 Not Acceptable ,因为它仅切换一个特定异常,而不是整个 CLR 组。

“那就写一个循环吧。”你说。但没那么快! Someone tried that already而且速度慢得毫无用处。 (是的,我已经证实它在我的系统上也很慢。)

因此,挑战在于使用宏在不到 1 或 2 秒的时间内切换整个 CLR 异常类别。 这个问题是重复的 Any have a Visual Studio shortcut/macro for toggling break on handled/unhandled exceptions?

最佳答案

与其他答案非常相似,但该组有一个特殊的 ExceptionSetting。

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

关于visual-studio - 使用宏或键盘快捷键切换 "Break when an exception is thrown.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/958011/

相关文章:

PHP:异常未被 try ... catch 捕获

c# - 暂停执行嵌入式 IronPython

visual-studio-2010 - 在 Visual Studio 中来回导航,类似于浏览器?

c++ - PROCESSENTERY32 结构中的 szExeFile 给出了一个奇怪的值

c# - 如何对 64 位 .NET 4.7 项目进行单元测试?

c# - 需要优化 C# 代码以将 CSV 行插入 MySql

c# - 从 wcf 到 asmx 的错误传播

exception - Kotlin协程异常处理——如何抽象try-catch

javascript - Aptana 和 JavaScript/jQuery IDE

java - 编写自定义重构脚本的最佳 Java 库是什么?