Debugger3.LastBreakReason 属性

获取程序中断的最终原因。 如果程序正在运行,它将返回 DBG_REASON_NONE

命名空间:  EnvDTE90
程序集:  EnvDTE90(在 EnvDTE90.dll 中)

语法

声明
ReadOnly Property LastBreakReason As dbgEventReason
dbgEventReason LastBreakReason { get; }
property dbgEventReason LastBreakReason {
    dbgEventReason get ();
}
abstract LastBreakReason : dbgEventReason with get
function get LastBreakReason () : dbgEventReason

属性值

类型:dbgEventReason
一个 dbgEventReason 值。

备注

程序有可能因为如下一些原因而中断:

如果未调试任何程序或调试器处于运行模式,则此属性将返回 dbgEventReasonNone

有关枚举的完整列表,请参见 dbgEventReason

示例

下面的示例演示如何使用 LastBreakReason 属性。

测试此属性:

  1. 在目标应用程序中设置一个断点。 运行外接程序。

  2. 以调试模式运行目标应用程序。

  3. 运行外接程序。

public static void LastBreakReason(EnvDTE80.DTE2 dte)
{
    // Setup debug Output window.
    Window w = 
    (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Last Break Reason 
    Test");
    owp.Activate();

    owp.OutputString("The reason that a program was broken: ");
    EnvDTE90.Debugger3 debugger = (EnvDTE90.Debugger3)dte.Debugger;
    switch (debugger.LastBreakReason)
    {
        case dbgEventReason.dbgEventReasonBreakpoint:
            owp.OutputString("Breakpoint hit.");
            break;
        case dbgEventReason.dbgEventReasonNone:
            owp.OutputString("No reason");
            break;
        case dbgEventReason.dbgEventReasonExceptionNotHandled:
            owp.OutputString("Exception not handled by the debuggee");
            break;
        case dbgEventReason.dbgEventReasonExceptionThrown:
            owp.OutputString("Exception thrown");
            break;
    }
}
Sub LastBreakReason()
    ' This function shows the reason break mode was entered
    ' in the Output window.
    Dim ow As OutputWindow
    ow = DTE2.Windows.Item(Constants.vsWindowKindOutput).Object

    Select Case DTE2.Debugger.LastBreakReason
        Case dbgEventReason.dbgEventReasonBreakpoint
            ow.ActivePane.OutputString("Breakpoint hit" + vbCrLf)

        Case dbgEventReason.dbgEventReasonNone
            ow.ActivePane.OutputString("No reason" + vbCrLf)

        Case dbgEventReason.dbgEventReasonExceptionNotHandled
            ow.ActivePane.OutputString("Exception not handled by the _
            debuggee" + vbCrLf)

        Case dbgEventReason.dbgEventReasonExceptionThrown
            ow.ActivePane.OutputString("Exception thrown" + vbCrLf)
    End Select
End Sub

.NET Framework 安全性

请参阅

参考

Debugger3 接口

EnvDTE90 命名空间