Właściwość Debugger.LastBreakReason —

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

Przestrzeń nazw:  EnvDTE
Zestaw:  EnvDTE (w EnvDTE.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: EnvDTE.dbgEventReason
A dbgEventReason value.

Uwagi

LastBreakReasonZwraca dbgEventReason wartość wskazującą, dlaczego program złamał.Program może być zerwane z jednej z następujących przyczyn:

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

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(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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

Debugger Interfejs

Przestrzeń nazw EnvDTE