Debugger.LastBreakReason 属性

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

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

语法

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

属性值

类型:EnvDTE.dbgEventReason
一个 dbgEventReason 值。

备注

LastBreakReason 返回一个指示程序中断原因的 dbgEventReason 值。 程序可因以下原因之一而中断:

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

示例

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

测试此属性:

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

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

  3. 运行外接程序。

public static void LastBreakReason(DTE dte)
{
    // Setup the 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: ");
    switch(dte.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;
    }
}
Shared Sub LastBreakReason(ByRef dte As EnvDTE.DTE)
    Select Case dte.Debugger.LastBreakReason
        Case dbgEventReason.dbgEventReasonBreakpoint
            MessageBox.Show("Breakpoint hit.", "Debugger Test - LastBreakReason")
        Case dbgEventReason.dbgEventReasonNone
            MessageBox.Show("No reason", "Debugger Test - LastBreakReason")
        Case dbgEventReason.dbgEventReasonExceptionNotHandled
            MessageBox.Show("Exception not handled by the debuggee", _
                            "Debugger Test - LastBreakReason")
        Case dbgEventReason.dbgEventReasonExceptionThrown
            MessageBox.Show("Exception thrown", "Debugger Test - LastBreakReason")
    End Select
End Sub

.NET Framework 安全性

请参阅

参考

Debugger 接口

EnvDTE 命名空间