AddInProcess.IsCurrentProcess 属性

定义

获取一个值,指示当前 AddInProcess 对象是否表示主机应用程序进程。

public:
 property bool IsCurrentProcess { bool get(); };
public bool IsCurrentProcess { get; }
member this.IsCurrentProcess : bool
Public ReadOnly Property IsCurrentProcess As Boolean

属性值

如果 AddInProcess 对象对应于当前进程,则为 true;否则为 false

示例

以下示例在外部进程中激活外接程序,并使用 IsCurrentProcess 属性确定外接程序是否与主机应用程序进程位于同一进程中。

// Create an external process.
AddInProcess pExternal = new AddInProcess();

// Activate an add-in in the external process
// with a full trust security level.
Calculator CalcAddIn4 =
    selectedToken.Activate<Calculator>(pExternal,
    AddInSecurityLevel.FullTrust);

// Show that the add-in is an external process
// by verifying that it is not in the current (host's) process.
AddInController AddinCtl = AddInController.GetAddInController(CalcAddIn4);
Console.WriteLine("Add-in in host's process: {0}",
    AddinCtl.AddInEnvironment.Process.IsCurrentProcess);
' Create an external process.
Dim pExternal As New AddInProcess()

' Activate an add-in in the external process
' with a full trust security level.
Dim CalcAddIn4 As Calculator = _
    selectedToken.Activate(Of Calculator)(pExternal, _
        AddInSecurityLevel.FullTrust)

' Show that the add-in is an external process
' by verifying that it is not in the current (host's) process.
Dim AddinCtl As AddInController = AddInController.GetAddInController(CalcAddIn4)
Console.WriteLine("Add-in in host's process: {0}", _
 AddinCtl.AddInEnvironment.Process.IsCurrentProcess)

注解

如果此属性 true的值为 ,则外接程序与主机应用程序一起在进程内运行。 在这种情况下,使用 StartShutdown 方法会 InvalidOperationException引发 。

注意

如果外接程序在进程内运行,则 AddInEnvironment.Process 属性返回一个 AddInProcess 对象,该对象表示主机应用程序进程。

适用于