共用方式為


Process3.Attach2 方法

它與 Attach 類似,會造成偵錯工具附加此處理序,不過它可允許您指定一個或一組引擎。

命名空間:  EnvDTE90
組件:  EnvDTE90 (在 EnvDTE90.dll 中)

語法

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

參數

  • Engines
    類型:Object

    Engines 集合。

備註

Attach2 讓您藉由使用指定的偵錯引擎或一組引擎,即可附加至處理序。 Engines 參數可以是單一 BSTR、BSTR 集合、單一 Engine 物件,或 Engine 物件集合。 如果將此參數指定為 BSTR,則可以使用引擎名稱的前幾個字元或引擎的 ID (GUID)。 引擎清單專用於某一特定 Transport

範例

' Macro code.
' The examples below illustrate how to attach to default, local, and 
' remote processes.
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports Microsoft.VisualBasic.ControlChars

Public Module Module1

    Sub NativeAttachToLocalCalc()
        Dim dbg2 As EnvDTE90.Debugger3
        dbg2 = DTE.Debugger

        Dim attached As Boolean = False
        Dim proc As EnvDTE90.Process3
        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 EnvDTE90.Debugger3
        dbg2 = DTE.Debugger

        Dim attached As Boolean = False
        Dim proc As EnvDTE90.Process3
        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

.NET Framework 安全性

請參閱

參考

Process3 介面

EnvDTE90 命名空間