This documentation is archived and is not being maintained.

Debugger.CurrentProcess Property

Sets or gets the active process.

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

Process CurrentProcess { get; set; }
/** @property */
Process get_CurrentProcess ()

/** @property */
void set_CurrentProcess (/** @attribute InAttribute() */ Process Process)

function get CurrentProcess () : Process

function set CurrentProcess (Process : Process)

Property Value

A Process object.

CurrentProcess sets or returns the active Process. The active process is the process 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 Programs for more information.

The following example demonstrates how to use the CurrentProcess property.

To test this property:

  1. Open the target application. Run the add-in. No process 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 process is being debugged.

public static void CurrentProcess(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 Process Test");

    owp.OutputString("Current Process Info: ");
    EnvDTE.Process process = dte.Debugger.CurrentProcess;
    if(process == null)
        owp.OutputString("No process is being debugged");
        owp.OutputString("Process ID = " + process.ProcessID + 
                         "  Process Name = " + process.Name);