Export (0) Print
Expand All

AppDomain.CreateDomain Method (String, Evidence, String, String, Boolean)

.NET Framework 1.1

Creates a new application domain with the given name, using evidence, application base path, relative search path, and a parameter that specifies whether a shadow copy of an assembly is to be loaded into the application domain.

[Visual Basic]
Overloads Public Shared Function CreateDomain( _
   ByVal friendlyName As String, _
   ByVal securityInfo As Evidence, _
   ByVal appBasePath As String, _
   ByVal appRelativeSearchPath As String, _
   ByVal shadowCopyFiles As Boolean _
) As AppDomain
[C#]
public static AppDomain CreateDomain(
 string friendlyName,
 Evidence securityInfo,
 string appBasePath,
 string appRelativeSearchPath,
 bool shadowCopyFiles
);
[C++]
public: static AppDomain* CreateDomain(
 String* friendlyName,
 Evidence* securityInfo,
 String* appBasePath,
 String* appRelativeSearchPath,
 bool shadowCopyFiles
);
[JScript]
public static function CreateDomain(
   friendlyName : String,
 securityInfo : Evidence,
 appBasePath : String,
 appRelativeSearchPath : String,
 shadowCopyFiles : Boolean
) : AppDomain;

Parameters

friendlyName
The friendly name of the domain. This friendly name can be displayed in user interfaces to identify the domain. For more information, see the description of FriendlyName.
securityInfo
Evidence mapped through the security policy to establish a top-of-stack permission set.
appBasePath
The base directory that the assembly resolver uses to probe for assemblies. For more information, see the description of BaseDirectory.
appRelativeSearchPath
The path relative to the base directory where the assembly resolver should probe for private assemblies. For more information, see the description of RelativeSearchPath.
shadowCopyFiles
If true, a shadow copy of an assembly is loaded into this application domain.

Return Value

The newly created application domain.

Exceptions

Exception Type Condition
SecurityException The caller does not have the correct permissions. See the requirements section.

Example

[Visual Basic, C#, C++] The following sample demonstrates, in general, how to create a domain using one of the CreateDomain overloads.

[Visual Basic] 
' Set up the AppDomainSetup
Dim setup As New AppDomainSetup()
setup.ApplicationBase = "(some directory)"
setup.ConfigurationFile = "(some file)"

' Set up the Evidence
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
evidence.AddAssembly("(some assembly)")
evidence.AddHost("(some host)")

' Create the AppDomain
Dim newDomain As AppDomain = AppDomain.CreateDomain("newDomain", evidence, setup)

[C#] 
// Set up the AppDomainSetup
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = "(some directory)";
setup.ConfigurationFile = "(some file)";

// Set up the Evidence
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
Evidence evidence = new Evidence(baseEvidence);
evidence.AddAssembly("(some assembly)");
evidence.AddHost("(some host)");

// Create the AppDomain      
AppDomain newDomain = AppDomain.CreateDomain("newDomain", evidence, setup);

[C++] 
// Set up the AppDomainSetup
AppDomainSetup* setup = new AppDomainSetup();
setup->ApplicationBase = S"(some directory)";
setup->ConfigurationFile = S"(some file)";

// Set up the Evidence
Evidence*  baseEvidence = AppDomain::CurrentDomain->Evidence;
Evidence* evidence = new Evidence(baseEvidence);
evidence->AddAssembly(S"(some assembly)");
evidence->AddHost(S"(some host)");

// Create the AppDomain
AppDomain*  newDomain = AppDomain::CreateDomain(S"newDomain", evidence, setup);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

AppDomain Class | AppDomain Members | System Namespace | AppDomain.CreateDomain Overload List

Show:
© 2014 Microsoft