Metodo Process2.Attach2

Analogamente a Attach, comporta il collegamento del debugger al processo corrente, l'unica differenza è che consente di specificare un modulo o un insieme di moduli.

Spazio dei nomi:  EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

Sintassi

'Dichiarazione
Sub Attach2 ( _
    Engines As Object _
)
void Attach2(
    Object Engines
)
void Attach2(
    [InAttribute] Object^ Engines
)
abstract Attach2 : 
        Engines:Object -> unit 
function Attach2(
    Engines : Object
)

Parametri

Note

Attach2 consente di connettersi a un processo utilizzando un insieme di moduli o un modulo di gestione di debug specifico. Il parametro Engines può essere dato da un singolo BSTR, da un insieme di BSTR, da un singolo oggetto Engine o da un insieme di oggetti Engine. Se viene specificato come BSTR, è possibile fornire il GUID o i primi caratteri del nome del modulo. L'elenco di moduli è specifico di un determinato oggetto Transport.

Esempi

' 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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Process2 Interfaccia

Spazio dei nomi EnvDTE80

Altre risorse

Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione