Debugger2.LastBreakReason Property

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

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


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

Property Value

Type: EnvDTE.dbgEventReason
A dbgEventReason value.




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.


The following example demonstrates how to use the LastBreakReason property.

To test this property:

  1. Set a breakpoint in the target application. Run the add-in.

  2. Run the target application in the debug mode.

  3. Run the add-in.

public static void LastBreakReason(EnvDTE80.DTE2 dte)
    // Setup debug Output window.
    Window w = 
    w.Visible = true;
    OutputWindow ow = (OutputWindow)w.Object;
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Last Break Reason 

    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.");
        case dbgEventReason.dbgEventReasonNone:
            owp.OutputString("No reason");
        case dbgEventReason.dbgEventReasonExceptionNotHandled:
            owp.OutputString("Exception not handled by the debuggee");
        case dbgEventReason.dbgEventReasonExceptionThrown:
            owp.OutputString("Exception thrown");
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

.NET Framework Security

See Also


Debugger2 Interface

EnvDTE80 Namespace