AddInToken.Activate(Of T) Method (AppDomain)


Activates an add-in in an existing application domain.

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

Public Function Activate(Of T) (
	target As AppDomain
) As T


Type: System.AppDomain

The application domain that the add-in should be activated 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.

Exception Condition

Full-trust permission is demanded. A caller in the call chain does not have sufficient permission.

To activate an add-in in an automatically generated application domain, use the Activate(Of T)(AddInSecurityLevel) overload to generate a new application domain with a specified security level or the Activate(Of T)(AddInSecurityLevel, String) overload to include a friendly name for the application domain.

The following example activates an add-in in an application domain that is being used by another add-in. The code for the first add-in is provided in the AddInToken class.

' Get the application domain
' of an existing add-in (CalcAddIn).

Dim aiCtrl As AddInController = AddInController.GetAddInController(CalcAddIn)
Dim AddInAppDom As AppDomain = aiCtrl.AppDomain

' Activate another add-in in the same appliation domain.
Dim CalcAddIn3 As Calculator = selectedToken2.Activate(Of Calculator)(AddInAppDom)

' Show that the CalcAddIn3 was loaded
' into CalcCaddIn's application domain.
Dim aic As AddInController = AddInController.GetAddInController(CalcAddIn3)
Console.WriteLine("Add-in loaded into existing application domain: {0}", _

.NET Framework
Available since 3.5
Return to top