Udostępnij za pośrednictwem


Właściwość Debugger2.LastBreakReason —

Pobiera ostatni powodem, dla którego program zostało przerwane.Jeśli program jest uruchomiony, to zwraca DBG_REASON_NONE.

Przestrzeń nazw:  EnvDTE80
Zestaw:  EnvDTE80 (w EnvDTE80.dll)

Składnia

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

Wartość właściwości

Typ: dbgEventReason
A dbgEventReason value.

Uwagi

Program może być przerwane, na przykład niektóre z następujących powodów:

Jeśli nic nie jest debugowany lub debugera jest w trybie uruchamiania, ta właściwość zwraca dbgEventReasonNone.

Aby uzyskać pełną listę wyliczeń, zobacz dbgEventReason.

Przykłady

Poniższy przykład demonstruje, jak używać LastBreakReason właściwości.

Aby przetestować tę właściwość:

  1. Ustawianie punktu przerwania w aplikacji docelowej.Uruchomienie dodatku.

  2. Uruchom aplikację docelową w trybie debugowania.

  3. Uruchomienie dodatku.

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: ");
    EnvDTE80.Debugger2 debugger = (EnvDTE80.Debugger2)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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

Debugger2 Interfejs

Przestrzeń nazw EnvDTE80