AddInToken.Activate(Of 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 Function Activate(Of T) (
	environment As AddInEnvironment
) As T


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.

Type Parameters


The interface or abstract base type that represents 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 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}", _
Console.WriteLine("Add-ins in same process: {0}", _

.NET Framework
Available since 3.5
Return to top