This documentation is archived and is not being maintained.

AppDomain.CreateDomain Method (String, Evidence)

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Shared Function CreateDomain( _
   ByVal friendlyName As String, _
   ByVal securityInfo As Evidence _
) As AppDomain
public static AppDomain CreateDomain(
 string friendlyName,
 Evidence securityInfo
public: static AppDomain* CreateDomain(
 String* friendlyName,
 Evidence* securityInfo
public static function CreateDomain(
   friendlyName : String,
 securityInfo : Evidence
) : AppDomain;


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.
Evidence mapped through the security policy to establish a top-of-stack permission set.

Return Value

The newly created application domain.


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


.NET Compact Framework Platform Note:  You must specify the second parameter, securityInfo, as a null reference (Nothing in Visual Basic) in version 1.0 of the .NET Compact Framework.


[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)

// 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);

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


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

.NET Framework Security: 

See Also

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