Partilhar via


Process2.Attach2(Object) Method

Definition

public:
 void Attach2(System::Object ^ Engines);
void Attach2(winrt::Windows::Foundation::IInspectable const & Engines = );
[System.Runtime.InteropServices.DispId(1001)]
public void Attach2 (object Engines = );
[System.Runtime.InteropServices.DispId(1001)]
public void Attach2 (object Engines);
[<System.Runtime.InteropServices.DispId(1001)>]
abstract member Attach2 : obj -> unit
Public Sub Attach2 (Optional Engines As Object = )
Public Sub Attach2 (Engines As Object)

Parameters

Engines
Object

Single String or an array of either String or Engine objects

Attributes

Examples

' 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  

Remarks

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.

Applies to