Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AppDomain.CreateDomain Method

Creates a new application domain.

Overload List

Creates a new application domain with the specified name.

[Visual Basic] Overloads Public Shared Function CreateDomain(String) As AppDomain
[C#] public static AppDomain CreateDomain(string);
[C++] public: static AppDomain* CreateDomain(String*);
[JScript] public static function CreateDomain(String) : AppDomain;

Creates a new application domain with the given name using the supplied evidence.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Shared Function CreateDomain(String, Evidence) As AppDomain
[C#] public static AppDomain CreateDomain(string, Evidence);
[C++] public: static AppDomain* CreateDomain(String*, Evidence*);
[JScript] public static function CreateDomain(String, Evidence) : AppDomain;

Creates a new application domain using the specified name, evidence, and application domain setup information.

[Visual Basic] Overloads Public Shared Function CreateDomain(String, Evidence, AppDomainSetup) As AppDomain
[C#] public static AppDomain CreateDomain(string, Evidence, AppDomainSetup);
[C++] public: static AppDomain* CreateDomain(String*, Evidence*, AppDomainSetup*);
[JScript] public static function CreateDomain(String, Evidence, AppDomainSetup) : AppDomain;

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(String, Evidence, String, String, Boolean) As AppDomain
[C#] public static AppDomain CreateDomain(string, Evidence, string, string, bool);
[C++] public: static AppDomain* CreateDomain(String*, Evidence*, String*, String*, bool);
[JScript] public static function CreateDomain(String, Evidence, String, String, Boolean) : AppDomain;

Example

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

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of CreateDomain. For other examples that might be available, see the individual overload topics.
[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.

See Also

AppDomain Class | AppDomain Members | System Namespace

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft