Condividi tramite


Debugger3.LastBreakReason Property

Definition

Gets the last reason that a program was broken. If the program is running it returns DBG_REASON_NONE.

public:
 property EnvDTE::dbgEventReason LastBreakReason { EnvDTE::dbgEventReason get(); };
public:
 property EnvDTE::dbgEventReason LastBreakReason { EnvDTE::dbgEventReason get(); };
[System.Runtime.InteropServices.DispId(109)]
public EnvDTE.dbgEventReason LastBreakReason { [System.Runtime.InteropServices.DispId(109)] get; }
[<System.Runtime.InteropServices.DispId(109)>]
[<get: System.Runtime.InteropServices.DispId(109)>]
member this.LastBreakReason : EnvDTE.dbgEventReason
Public ReadOnly Property LastBreakReason As dbgEventReason

Property Value

A dbgEventReason value.

Implements

Attributes

Examples

The following example shows how to use the LastBreakReason property.

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

Remarks

A program can be broken, for example, for some of the following reasons:

If nothing is being debugged or the debugger is in run mode, this property returns dbgEventReasonNone.

For a complete list of enumerations, see dbgEventReason.

Applies to