This documentation is archived and is not being maintained.

AddInToken.Activate<T> Method (AppDomain)

Activates an add-in in an existing application domain.

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

public T Activate<T>(
	AppDomain target
)

Type Parameters

T

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

Parameters

target
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.

To activate an add-in in an automatically generated application domain, use the Activate<T>(AddInSecurityLevel) overload to generate a new application domain with a specified security level or the Activate<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).
AddInController aiCtrl = AddInController.GetAddInController(CalcAddIn);
AppDomain AddInAppDom = aiCtrl.AppDomain;

// Activate another add-in in the same application domain.
Calculator CalcAddIn3 =
	selectedToken2.Activate<Calculator>(AddInAppDom);

// Show that CalcAddIn3 was loaded 
// into CalcAddIn's application domain.
AddInController aic = AddInController.GetAddInController(CalcAddIn3);
Console.WriteLine("Add-in loaded into existing application domain: {0}",
	aic.AppDomain.Equals(AddInAppDom));

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
Show: