Process.Attach Method

Causes the debugger to attach this process.

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

Syntax

'Declaration
Sub Attach
void Attach()
void Attach()
abstract Attach : unit -> unit
function Attach()

Examples

The following example demonstrates how to use the Attach method.

To test this method

  1. Run the target application in the nondebug mode. Make sure that the application contains an infinite loop.

  2. Run the add-in.

  3. Set the breakpoint inside the infinite loop.

public static void Attach(DTE dte)
{
    EnvDTE.Processes processes = dte.Debugger.LocalProcesses;
    foreach(EnvDTE.Process proc in processes)
        if(proc.Name.IndexOf("Target.exe") != -1)
            proc.Attach();
}
Shared Sub Attach(ByRef dte As EnvDTE.DTE)
    Dim processes As EnvDTE.Processes = dte.Debugger.LocalProcesses
    For Each proc As EnvDTE.Process In processes
        If proc.Name.IndexOf("Target.exe") <> -1 Then
            proc.Attach()
        End If
    Next
End Sub

.NET Framework Security

See Also

Reference

Process Interface

EnvDTE Namespace

Other Resources

Attach to Running Processes with the Visual Studio Debugger