共用方式為


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
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 命名空間