Export (0) Print
Expand All

AddInToken.Activate<T> Method (AddInEnvironment)

Activates an add-in in the environment of another add-in.

Namespace:  System.AddIn.Hosting
Assembly:  System.AddIn (in System.AddIn.dll)

public T Activate<T>(
	AddInEnvironment environment
)

Type Parameters

T

The interface or abstract base type that represents the host view of the add-in.

Parameters

environment
Type: System.AddIn.Hosting.AddInEnvironment

The application domain and process that contains the original add-in.

Return Value

Type: T
The host view of the add-in.

This method overload activates the add-in in the same application domain and process as the add-in from which environment was obtained.

The following example activates one add-in in an automatically generated application domain with a specified security level. It then activates a second add-in in the same application domain and process as the first by using the first add-in's AddInEnvironment object.

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

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2014 Microsoft