Process2::Attach2 Method (Object^)
Visual Studio 2015
Similar to Attach, causes the debugger to attach this process, only it allows you to specify an engine or set of engines.
Assembly: EnvDTE80 (in EnvDTE80.dll)
Attach2 allows you to attach to a process using a specific debugging engine or set of engines. The Engines parameter can be a single BSTR, a collection of BSTRs, a single Engine object or a collection of Engine objects. If specified as a BSTR, the first few chars of the engine name or it's ID (GUID) can be supplied. The list of engines is specific to a given Transport.
' Macro code. ' The examples below illustrate how to attach to default, local, and ' remote processes. Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics Imports Microsoft.VisualBasic.ControlChars Public Module Module1 Sub NativeAttachToLocalCalc() Dim dbg2 As EnvDTE80.Debugger2 dbg2 = DTE.Debugger Dim attached As Boolean = False Dim proc As EnvDTE80.Process2 For Each proc In DTE.Debugger.LocalProcesses If (Right(proc.Name, 8) = "calc.exe") Then proc.Attach2("native") attached = True Exit For End If Next If attached = False Then If attached = False Then MsgBox("calc.exe isn't running") End If End If End Sub Sub DefaultAttachToLocalCalc() Dim dbg2 As EnvDTE80.Debugger2 dbg2 = DTE.Debugger Dim attached As Boolean = False Dim proc As EnvDTE80.Process2 For Each proc In DTE.Debugger.LocalProcesses If (Right(proc.Name, 8) = "calc.exe") Then proc.Attach2() attached = True Exit For End If Next If attached = False Then If attached = False Then MsgBox("calc.exe isn't running") End If End If End Sub End Module
Show: