Udostępnij za pośrednictwem


Debugger.CurrentProgram Property

Sets or gets the active program.

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

Syntax

'Declaration
Property CurrentProgram As Program
Program CurrentProgram { get; set; }
property Program^ CurrentProgram {
    Program^ get ();
    void set (Program^ value);
}
abstract CurrentProgram : Program with get, set
function get CurrentProgram () : Program
function set CurrentProgram (value : Program)

Property Value

Type: EnvDTE.Program
The active Program.

Remarks

CurrentProgram sets or returns the active Program. The active program is the program that defines the data displayed by the debugger. Although the debugger supports debugging more than one process at a time, only one process can be active at any given time. See Debugging Multiple Processes for more information.

Examples

The following example demonstrates how to use the CurrentProgram property.

To test this property:

  1. Open the target application. Run the add-in. No program is being debugged.

  2. Set a breakpoint in the target application. Run the application in the debug mode.

  3. When the program stops on the breakpoint, run the add-in. The program is being debugged.

public static void CurrentProgram(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("Current Program Test");
    owp.Activate();

    owp.OutputString("Current Program Info: ");
    EnvDTE.Program program = dte.Debugger.CurrentProgram;
    if(program == null)
        owp.OutputString("No program is being debugged");
    else
        owp.OutputString("Program Name = " + program.Name);
}
Shared Sub CurrentProgram(ByRef dte As EnvDTE.DTE)
    Dim program As EnvDTE.Program = dte.Debugger.CurrentProgram
    If program Is Nothing Then
        MessageBox.Show("No program is being debugged", _
                        "Debugger Test - Current Program Info")
    Else
        MessageBox.Show("Program Name = " + _
                        program.Name, "Debugger Test - Current Program Info")
    End If
End Sub

.NET Framework Security

See Also

Reference

Debugger Interface

EnvDTE Namespace

Debugger