Compartilhar via


Propriedade Debugger2.LastBreakReason

Obtém o último motivo pelo qual um programa foi interrompido. Se o programa é executado ele retorna DBG_REASON_NONE.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (em EnvDTE80.dll)

Sintaxe

'Declaração
ReadOnly Property LastBreakReason As dbgEventReason
dbgEventReason LastBreakReason { get; }
property dbgEventReason LastBreakReason {
    dbgEventReason get ();
}
abstract LastBreakReason : dbgEventReason with get
function get LastBreakReason () : dbgEventReason

Valor de propriedade

Tipo: dbgEventReason
Um valor dbgEventReason.

Comentários

Um programa pode ser interrompido, por exemplo, para alguns dos seguintes motivos:

Se nada está sendo depurado ou o depurador está no modo de execução, essa propriedade retornará dbgEventReasonNone.

Para obter uma lista completa das enumerações, consulte dbgEventReason.

Exemplos

O exemplo a seguir demonstra como usar o LastBreakReason propriedade.

Para testar essa propriedade:

  1. Defina um ponto de interrupção no aplicativo de destino. Execute o add-in.

  2. Execute o aplicativo de destino no modo de depuração.

  3. Execute o add-in.

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

Segurança do .NET Framework

Consulte também

Referência

Debugger2 Interface

Namespace EnvDTE80