AppDomain.CreateDomain AppDomain.CreateDomain AppDomain.CreateDomain AppDomain.CreateDomain Method

定义

创建新的应用程序域。Creates a new application domain.

重载

CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[])

使用证据、应用程序基路径、相对搜索路径和指定是否向应用程序域中加载程序集的影像副本的形参创建具有给定名称的新应用程序域。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. 指定在初始化应用程序域时调用的回调方法,以及传递回调方法的字符串实参数组。Specifies a callback method that is invoked when the application domain is initialized, and an array of string arguments to pass the callback method.

CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean)

使用证据、应用程序基路径、相对搜索路径和指定是否向应用程序域中加载程序集的影像副本的形参创建具有给定名称的新应用程序域。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.

CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])

使用指定的名称、证据、应用程序域设置信息、默认权限集和一组完全受信任的程序集创建新的应用程序域。Creates a new application domain using the specified name, evidence, application domain setup information, default permission set, and array of fully trusted assemblies.

CreateDomain(String, Evidence) CreateDomain(String, Evidence) CreateDomain(String, Evidence) CreateDomain(String, Evidence)

使用所提供的证据创建具有给定名称的新应用程序域。Creates a new application domain with the given name using the supplied evidence.

CreateDomain(String) CreateDomain(String) CreateDomain(String) CreateDomain(String)

使用指定的名称新建应用程序域。Creates a new application domain with the specified name.

CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup)

使用指定的名称、证据和应用程序域设置信息创建新的应用程序域。Creates a new application domain using the specified name, evidence, and application domain setup information.

CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[]) CreateDomain(String, Evidence, String, String, Boolean, AppDomainInitializer, String[])

使用证据、应用程序基路径、相对搜索路径和指定是否向应用程序域中加载程序集的影像副本的形参创建具有给定名称的新应用程序域。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. 指定在初始化应用程序域时调用的回调方法,以及传递回调方法的字符串实参数组。Specifies a callback method that is invoked when the application domain is initialized, and an array of string arguments to pass the callback method.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName, System::Security::Policy::Evidence ^ securityInfo, System::String ^ appBasePath, System::String ^ appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer ^ adInit, cli::array <System::String ^> ^ adInitArgs);
public static AppDomain CreateDomain (string friendlyName, System.Security.Policy.Evidence securityInfo, string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles, AppDomainInitializer adInit, string[] adInitArgs);
static member CreateDomain : string * System.Security.Policy.Evidence * string * string * bool * AppDomainInitializer * string[] -> AppDomain
Public Shared Function CreateDomain (friendlyName As String, securityInfo As Evidence, appBasePath As String, appRelativeSearchPath As String, shadowCopyFiles As Boolean, adInit As AppDomainInitializer, adInitArgs As String()) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain. 此友好名称可在用户界面中显示以标识域。This friendly name can be displayed in user interfaces to identify the domain. 有关更多信息,请参见FriendlyNameFor more information, see FriendlyName.

securityInfo
Evidence Evidence Evidence Evidence

确定代码标识的证据,该代码在应用程序域中运行。Evidence that establishes the identity of the code that runs in the application domain. 传递 null 以使用当前应用程序域的证据。Pass null to use the evidence of the current application domain.

appBasePath
String String String String

基目录,由程序集冲突解决程序用来探测程序集。The base directory that the assembly resolver uses to probe for assemblies. 有关更多信息,请参见BaseDirectoryFor more information, see BaseDirectory.

appRelativeSearchPath
String String String String

相对于基目录的路径,在此程序集冲突解决程序应探测专用程序集。The path relative to the base directory where the assembly resolver should probe for private assemblies. 有关更多信息,请参见RelativeSearchPathFor more information, see RelativeSearchPath.

shadowCopyFiles
Boolean Boolean Boolean Boolean

如果为 true,则将程序集的卷影副本加载到应用程序域中。true to load a shadow copy of an assembly into the application domain.

adInit
AppDomainInitializer AppDomainInitializer AppDomainInitializer AppDomainInitializer

AppDomainInitializer 委托,表示初始化新的 AppDomain 对象时调用的回调方法。An AppDomainInitializer delegate that represents a callback method to invoke when the new AppDomain object is initialized.

adInitArgs
String[]

字符串实参数组,在初始化新的 AppDomain 对象时传递给由 adInit 表示的回调。An array of string arguments to be passed to the callback represented by adInit, when the new AppDomain object is initialized.

返回

新创建的应用程序域。The newly created application domain.

异常

注解

所表示adInit的方法在新创建的应用程序域的上下文中执行。The method represented by adInit is executed in the context of the newly created application domain.

如果securityInfo未提供, 则使用当前应用程序域中的证据。If securityInfo is not supplied, the evidence from the current application domain is used.

有关卷影复制的详细信息, ShadowCopyFiles请参阅和卷影复制程序集For more information about shadow copying, see ShadowCopyFiles and Shadow Copying Assemblies.

重要

不要使用此方法重载来创建沙盒应用程序域。Do not use this method overload to create sandboxed application domains. 从开始securityInfo , 提供的证据不再影响应用程序域的授予集。 .NET Framework 4.NET Framework 4Beginning with the .NET Framework 4.NET Framework 4, the evidence that is supplied for securityInfo no longer affects the grant set of the application domain. CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])使用方法重载创建沙盒应用程序域。Use the CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) method overload to create sandboxed application domains.

安全性

SecurityPermission
提供证据。to provide evidence. 关联枚举:ControlEvidenceAssociated enumeration: ControlEvidence.

CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean) CreateDomain(String, Evidence, String, String, Boolean)

使用证据、应用程序基路径、相对搜索路径和指定是否向应用程序域中加载程序集的影像副本的形参创建具有给定名称的新应用程序域。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.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName, System::Security::Policy::Evidence ^ securityInfo, System::String ^ appBasePath, System::String ^ appRelativeSearchPath, bool shadowCopyFiles);
public static AppDomain CreateDomain (string friendlyName, System.Security.Policy.Evidence securityInfo, string appBasePath, string appRelativeSearchPath, bool shadowCopyFiles);
static member CreateDomain : string * System.Security.Policy.Evidence * string * string * bool -> AppDomain
Public Shared Function CreateDomain (friendlyName As String, securityInfo As Evidence, appBasePath As String, appRelativeSearchPath As String, shadowCopyFiles As Boolean) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain. 此友好名称可在用户界面中显示以标识域。This friendly name can be displayed in user interfaces to identify the domain. 有关更多信息,请参见FriendlyNameFor more information, see FriendlyName.

securityInfo
Evidence Evidence Evidence Evidence

确定代码标识的证据,该代码在应用程序域中运行。Evidence that establishes the identity of the code that runs in the application domain. 传递 null 以使用当前应用程序域的证据。Pass null to use the evidence of the current application domain.

appBasePath
String String String String

基目录,由程序集冲突解决程序用来探测程序集。The base directory that the assembly resolver uses to probe for assemblies. 有关更多信息,请参见BaseDirectoryFor more information, see BaseDirectory.

appRelativeSearchPath
String String String String

相对于基目录的路径,在此程序集冲突解决程序应探测专用程序集。The path relative to the base directory where the assembly resolver should probe for private assemblies. 有关更多信息,请参见RelativeSearchPathFor more information, see RelativeSearchPath.

shadowCopyFiles
Boolean Boolean Boolean Boolean

如果为 true,则向此应用程序域中加载程序集的卷影副本。If true, a shadow copy of an assembly is loaded into this application domain.

返回

新创建的应用程序域。The newly created application domain.

异常

示例

下面的示例演示了如何使用其中一个CreateDomain重载创建域。The following sample demonstrates, in general, how to create a domain using one of the CreateDomain overloads.

// Set up the AppDomainSetup
AppDomainSetup^ setup = gcnew AppDomainSetup;
setup->ApplicationBase = "(some directory)";
setup->ConfigurationFile = "(some file)";

// Set up the Evidence
Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
Evidence^ evidence = gcnew 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 = "(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
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)

注解

如果securityInfo未提供, 则使用当前应用程序域中的证据。If securityInfo is not supplied, the evidence from the current application domain is used.

有关卷影复制的详细信息, ShadowCopyFiles请参阅和卷影复制程序集For more information about shadow copying, see ShadowCopyFiles and Shadow Copying Assemblies.

重要

不要使用此方法重载来创建沙盒应用程序域。Do not use this method overload to create sandboxed application domains. 从开始securityInfo , 提供的证据不再影响应用程序域的授予集。 .NET Framework 4.NET Framework 4Beginning with the .NET Framework 4.NET Framework 4, the evidence that is supplied for securityInfo no longer affects the grant set of the application domain. CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])使用方法重载创建沙盒应用程序域。Use the CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) method overload to create sandboxed application domains.

安全性

SecurityPermission
提供证据。to provide evidence. 关联枚举:ControlEvidenceAssociated enumeration: ControlEvidence.

CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])

使用指定的名称、证据、应用程序域设置信息、默认权限集和一组完全受信任的程序集创建新的应用程序域。Creates a new application domain using the specified name, evidence, application domain setup information, default permission set, and array of fully trusted assemblies.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName, System::Security::Policy::Evidence ^ securityInfo, AppDomainSetup ^ info, System::Security::PermissionSet ^ grantSet, ... cli::array <System::Security::Policy::StrongName ^> ^ fullTrustAssemblies);
public static AppDomain CreateDomain (string friendlyName, System.Security.Policy.Evidence securityInfo, AppDomainSetup info, System.Security.PermissionSet grantSet, params System.Security.Policy.StrongName[] fullTrustAssemblies);
static member CreateDomain : string * System.Security.Policy.Evidence * AppDomainSetup * System.Security.PermissionSet * System.Security.Policy.StrongName[] -> AppDomain
Public Shared Function CreateDomain (friendlyName As String, securityInfo As Evidence, info As AppDomainSetup, grantSet As PermissionSet, ParamArray fullTrustAssemblies As StrongName()) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain. 此友好名称可在用户界面中显示以标识域。This friendly name can be displayed in user interfaces to identify the domain. 有关更多信息,请参见 FriendlyName 的说明。For more information, see the description of FriendlyName.

securityInfo
Evidence Evidence Evidence Evidence

确定代码标识的证据,该代码在应用程序域中运行。Evidence that establishes the identity of the code that runs in the application domain. 传递 null 以使用当前应用程序域的证据。Pass null to use the evidence of the current application domain.

info
AppDomainSetup AppDomainSetup AppDomainSetup AppDomainSetup

包含应用程序域初始化信息的对象。An object that contains application domain initialization information.

grantSet
PermissionSet PermissionSet PermissionSet PermissionSet

一个默认权限集,被授予加载到新应用程序域的所有无特定权限的程序集。A default permission set that is granted to all assemblies loaded into the new application domain that do not have specific grants.

fullTrustAssemblies
StrongName[]

一组强名称,表示在新应用程序域中被认为完全受信任的程序集。An array of strong names representing assemblies to be considered fully trusted in the new application domain.

返回

新创建的应用程序域。The newly created application domain.

异常

应用程序域为 nullThe application domain is null.

- 或 --or- ApplicationBase 属性在为 info 提供的 AppDomainSetup 对象上没有设置。The ApplicationBase property is not set on the AppDomainSetup object that is supplied for info.

注解

必须设置ApplicationBaseAppDomainSetup 提供的info对象的属性。You must set the ApplicationBase property of the AppDomainSetup object that you supply for info. 否则会引发异常。Otherwise, an exception is thrown.

如果securityInfo未提供, 则使用当前应用程序域中的证据。If securityInfo is not supplied, the evidence from the current application domain is used.

grantSet ApplicationTrustfullTrustAssemblies提供的信息用于为新的应用程序域创建对象。The information provided for grantSet and fullTrustAssemblies is used to create an ApplicationTrust object for the new application domain.

安全性

SecurityPermission
用于创建和操作应用程序域的功能。for the ability to create and manipulate an application domain. 关联枚举:ControlAppDomainAssociated enumeration: ControlAppDomain. 安全操作: DemandSecurity action: Demand.

CreateDomain(String, Evidence) CreateDomain(String, Evidence) CreateDomain(String, Evidence) CreateDomain(String, Evidence)

使用所提供的证据创建具有给定名称的新应用程序域。Creates a new application domain with the given name using the supplied evidence.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName, System::Security::Policy::Evidence ^ securityInfo);
public static AppDomain CreateDomain (string friendlyName, System.Security.Policy.Evidence securityInfo);
static member CreateDomain : string * System.Security.Policy.Evidence -> AppDomain
Public Shared Function CreateDomain (friendlyName As String, securityInfo As Evidence) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain. 此友好名称可在用户界面中显示以标识域。This friendly name can be displayed in user interfaces to identify the domain. 有关更多信息,请参见FriendlyNameFor more information, see FriendlyName.

securityInfo
Evidence Evidence Evidence Evidence

确定代码标识的证据,该代码在应用程序域中运行。Evidence that establishes the identity of the code that runs in the application domain. 传递 null 以使用当前应用程序域的证据。Pass null to use the evidence of the current application domain.

返回

新创建的应用程序域。The newly created application domain.

异常

示例

下面的示例演示了如何使用其中一个CreateDomain重载创建域。The following sample demonstrates, in general, how to create a domain using one of the CreateDomain overloads.

// Set up the AppDomainSetup
AppDomainSetup^ setup = gcnew AppDomainSetup;
setup->ApplicationBase = "(some directory)";
setup->ConfigurationFile = "(some file)";

// Set up the Evidence
Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
Evidence^ evidence = gcnew 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 = "(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
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)

注解

此方法重载使用来自AppDomainSetup默认应用程序域的信息。This method overload uses the AppDomainSetup information from the default application domain.

如果securityInfo未提供, 则使用当前应用程序域中的证据。If securityInfo is not supplied, the evidence from the current application domain is used.

重要

不要使用此方法重载来创建沙盒应用程序域。Do not use this method overload to create sandboxed application domains. 从开始securityInfo , 提供的证据不再影响应用程序域的授予集。 .NET Framework 4.NET Framework 4Beginning with the .NET Framework 4.NET Framework 4, the evidence that is supplied for securityInfo no longer affects the grant set of the application domain. CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])使用方法重载创建沙盒应用程序域。Use the CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) method overload to create sandboxed application domains.

安全性

SecurityPermission
提供证据。to provide evidence. 关联枚举:ControlEvidenceAssociated enumeration: ControlEvidence.

CreateDomain(String) CreateDomain(String) CreateDomain(String) CreateDomain(String)

使用指定的名称新建应用程序域。Creates a new application domain with the specified name.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName);
public static AppDomain CreateDomain (string friendlyName);
static member CreateDomain : string -> AppDomain
Public Shared Function CreateDomain (friendlyName As String) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain.

返回

新创建的应用程序域。The newly created application domain.

异常

方法在 .NET Core 上不受支持。Method not supported on .NET Core.

示例

下面的示例演示了如何使用其中一个CreateDomain重载创建域。The following sample demonstrates, in general, how to create a domain using one of the CreateDomain overloads.

// Set up the AppDomainSetup
AppDomainSetup^ setup = gcnew AppDomainSetup;
setup->ApplicationBase = "(some directory)";
setup->ConfigurationFile = "(some file)";

// Set up the Evidence
Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
Evidence^ evidence = gcnew 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 = "(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
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)

注解

friendlyName参数用于标识域, 这种方式对于人来说是有意义的。The friendlyName parameter is intended to identify the domain in a manner that is meaningful to humans. 此字符串应适合在用户界面中显示。This string should be suitable for display in user interfaces.

此方法重载使用来自AppDomainSetup默认应用程序域的信息。This method overload uses the AppDomainSetup information from the default application domain.

安全性

SecurityPermission
提供证据。to provide evidence. 关联枚举:ControlEvidenceAssociated enumeration: ControlEvidence.

另请参阅

CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup) CreateDomain(String, Evidence, AppDomainSetup)

使用指定的名称、证据和应用程序域设置信息创建新的应用程序域。Creates a new application domain using the specified name, evidence, and application domain setup information.

public:
 static AppDomain ^ CreateDomain(System::String ^ friendlyName, System::Security::Policy::Evidence ^ securityInfo, AppDomainSetup ^ info);
public static AppDomain CreateDomain (string friendlyName, System.Security.Policy.Evidence securityInfo, AppDomainSetup info);
static member CreateDomain : string * System.Security.Policy.Evidence * AppDomainSetup -> AppDomain
Public Shared Function CreateDomain (friendlyName As String, securityInfo As Evidence, info As AppDomainSetup) As AppDomain

参数

friendlyName
String String String String

域的友好名称。The friendly name of the domain. 此友好名称可在用户界面中显示以标识域。This friendly name can be displayed in user interfaces to identify the domain. 有关更多信息,请参见FriendlyNameFor more information, see FriendlyName.

securityInfo
Evidence Evidence Evidence Evidence

确定代码标识的证据,该代码在应用程序域中运行。Evidence that establishes the identity of the code that runs in the application domain. 传递 null 以使用当前应用程序域的证据。Pass null to use the evidence of the current application domain.

info
AppDomainSetup AppDomainSetup AppDomainSetup AppDomainSetup

包含应用程序域初始化信息的对象。An object that contains application domain initialization information.

返回

新创建的应用程序域。The newly created application domain.

异常

示例

下面的示例演示了如何使用其中一个CreateDomain重载创建域。The following sample demonstrates, in general, how to create a domain using one of the CreateDomain overloads.

// Set up the AppDomainSetup
AppDomainSetup^ setup = gcnew AppDomainSetup;
setup->ApplicationBase = "(some directory)";
setup->ConfigurationFile = "(some file)";

// Set up the Evidence
Evidence^ baseEvidence = AppDomain::CurrentDomain->Evidence;
Evidence^ evidence = gcnew 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 = "(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
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)

注解

如果info未提供, 此方法重载将使用来自AppDomainSetup默认应用程序域的信息。If info is not supplied, this method overload uses the AppDomainSetup information from the default application domain.

如果securityInfo未提供, 则使用当前应用程序域中的证据。If securityInfo is not supplied, the evidence from the current application domain is used.

重要

不要使用此方法重载来创建沙盒应用程序域。Do not use this method overload to create sandboxed application domains. 从开始securityInfo , 提供的证据不再影响应用程序域的授予集。 .NET Framework 4.NET Framework 4Beginning with the .NET Framework 4.NET Framework 4, the evidence that is supplied for securityInfo no longer affects the grant set of the application domain. CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[])使用方法重载创建沙盒应用程序域。Use the CreateDomain(String, Evidence, AppDomainSetup, PermissionSet, StrongName[]) method overload to create sandboxed application domains.

安全性

SecurityPermission
提供证据。to provide evidence. 关联枚举:ControlEvidenceAssociated enumeration: ControlEvidence.

适用于