通过


AddInProcess 类

定义

提供用于从主机应用程序运行进程外加载项的外部进程。

public ref class AddInProcess sealed
public sealed class AddInProcess
type AddInProcess = class
Public NotInheritable Class AddInProcess
继承
AddInProcess

示例

以下示例在外部进程中激活加载项。

// 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)

注解

若要在外部进程中激活加载项,请将对象 AddInProcess 传递给相应的 AddInToken.Activate<T>(AddInProcess, PermissionSet) 方法重载。

运行外接程序的可执行文件是从安装在 Windows 目录下的 .NET Framework 的两个文件之一获取的。 默认情况下,使用与主机应用程序的每字位匹配的可执行文件。 如果主机是 64 位进程,则运行 AddInProcess.exe;否则,将运行 AddInProcess32.exe。 若要指定可执行文件的选择方式,请使用 AddInProcess(Platform) 构造函数创建 AddInProcess 对象。

构造函数

名称 说明
AddInProcess()

初始化 AddInProcess 类的新实例。

AddInProcess(Platform)

初始化类的新实例 AddInProcess ,指定运行外接程序的进程的每字位。

属性

名称 说明
IsCurrentProcess

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

KeepAlive

获取或设置一个值,该值指示是否使外部进程保持活动状态。

Platform

获取运行进程外加载项的进程的每字位。

ProcessId

获取外部进程的进程 ID。

StartupTimeout

获取或设置允许进程启动的秒数。

方法

名称 说明
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
Shutdown()

强行关闭外部进程。

Start()

启动外部进程。

ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

活动

名称 说明
ShuttingDown

当对象表示 AddInProcess 的进程即将关闭时发生。

适用于