Process2.Attach2 方法
与 Attach 类似,会使调试器附加该进程,只有它允许您指定一个或一组引擎。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.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
类型:System.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 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
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。