AddInController.AddInEnvironment 属性

定义

获取一个 AddInEnvironment 对象。

public:
 property System::AddIn::Hosting::AddInEnvironment ^ AddInEnvironment { System::AddIn::Hosting::AddInEnvironment ^ get(); };
public System.AddIn.Hosting.AddInEnvironment AddInEnvironment { get; }
member this.AddInEnvironment : System.AddIn.Hosting.AddInEnvironment
Public ReadOnly Property AddInEnvironment As AddInEnvironment

属性值

一个对象,可用于激活与原始外接程序在同一环境中的其他外接程序。

示例

以下示例在与第一个外接程序相同的环境中激活第二个外接程序。

// Get the AddInController of a
// currently actived add-in (CalcAddIn).
AddInController aiController = AddInController.GetAddInController(CalcAddIn);

// Select another token.
AddInToken selectedToken2 = ChooseAddIn(tokens);

// Activate a second add-in, CalcAddIn2, in the same
// appliation domain and process as the first add-in by passing
// the first add-in's AddInEnvironment object to the Activate method.
AddInEnvironment aiEnvironment = aiController.AddInEnvironment;
Calculator CalcAddIn2 =
    selectedToken2.Activate<Calculator>(aiEnvironment);

// Get the AddInController for the second add-in to compare environments.
AddInController aiController2 = AddInController.GetAddInController(CalcAddIn2);
Console.WriteLine("Add-ins in same application domain: {0}", aiController.AppDomain.Equals(aiController2.AppDomain));
Console.WriteLine("Add-ins in same process: {0}", aiEnvironment.Process.Equals(aiController2.AddInEnvironment.Process));
' Get the AddInController of a 
' currently activated add-in (CalcAddIn).
Dim aiController As AddInController = AddInController.GetAddInController(CalcAddIn)

' Select another token.
Dim selectedToken2 As AddInToken = ChooseAddIn(tokens)

' Activate a second add-in, CalcAddIn2, in the same
' appliation domain and process as the first add-in by passing
' the first add-in's AddInEnvironment object to the Activate method.

Dim aiEnvironment As AddInEnvironment = aiController.AddInEnvironment
Dim CalcAddIn2 As Calculator = _
    selectedToken2.Activate(Of Calculator)(aiEnvironment)

' Get the AddInController for the second add-in to compare environments.
Dim aiController2 As AddInController = AddInController.GetAddInController(CalcAddIn2)

Console.WriteLine("Add-ins in same application domain: {0}", _
    aiController.AppDomain.Equals(aiController2.AppDomain))
Console.WriteLine("Add-ins in same process: {0}", _
    aiEnvironment.Process.Equals(aiController2.AddInEnvironment.Process))

注解

使用此属性可获取 AddInEnvironment 外接程序的对象。 然后,使用该对象激活与原始外接程序相同的应用程序域和进程中的其他加载项。

适用于