AppDomainSetup.ApplicationBase 属性
获取或设置包含该应用程序的目录的名称。
**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public Property ApplicationBase As String
用法
Dim instance As AppDomainSetup
Dim value As String
value = instance.ApplicationBase
instance.ApplicationBase = value
public string ApplicationBase { get; set; }
public:
virtual property String^ ApplicationBase {
String^ get () sealed;
void set (String^ value) sealed;
}
/** @property */
public final String get_ApplicationBase ()
/** @property */
public final void set_ApplicationBase (String value)
public final function get ApplicationBase () : String
public final function set ApplicationBase (value : String)
属性值
包含应用程序基目录名称的 String。
备注
应用程序基目录是程序集管理器进行程序集探测的起始位置。
ApplicationBase 属性可以影响授予应用程序域的权限。例如,从本地计算机起源的应用程序域通常根据其起源位置而受到完全信任。但如果 AppDomain 的 ApplicationBase 属性被置为某个 Intranet 目录的全名,则 ApplicationBase 设置会将授予应用程序域的权限设置为 LocalIntranet 授予的权限,即使应用程序域实际起源于本地计算机也是如此。
示例
Imports System
Imports System.Reflection
Imports System.Security.Policy 'for evidence object
Class ADSetupInformation
Public Shared Sub Main()
' Create the applcation domain setup information.
Dim domaininfo As New AppDomainSetup()
domaininfo.ApplicationBase = System.Environment.CurrentDirectory
'Create evidence for the new appdomain.
Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
' Create the new application domain using setup information.
Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo)
' Write out the application domain information.
Console.WriteLine(("Host domain: " + AppDomain.CurrentDomain.FriendlyName))
Console.WriteLine(("new child domain: " + domain.FriendlyName))
Console.WriteLine()
Console.WriteLine(("Application base is: " + domain.SetupInformation.ApplicationBase))
AppDomain.Unload(domain)
End Sub 'Main
End Class 'ADSetupInformation
using System;
using System.Reflection;
using System.Security.Policy; //for evidence object
class ADSetupInformation
{
public static void Main()
{
//Create the application domain setup information.
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase = System.Environment.CurrentDirectory;
//Create evidence for new appdomain.
Evidence adevidence = AppDomain.CurrentDomain.Evidence;
// Create the new application domain using setup information.
AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);
// Write out the application domain information.
Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine("new child domain: " + domain.FriendlyName);
Console.WriteLine();
Console.WriteLine("Application base is: " + domain.SetupInformation.ApplicationBase);
AppDomain.Unload(domain);
}
}
using namespace System;
using namespace System::Reflection;
using namespace System::Security::Policy;
//for evidence Object
int main()
{
//Create the application domain setup information.
AppDomainSetup^ domaininfo = gcnew AppDomainSetup;
domaininfo->ApplicationBase = System::Environment::CurrentDirectory;
//Create evidence for new appdomain.
Evidence^ adevidence = AppDomain::CurrentDomain->Evidence;
// Create the new application domain using setup information.
AppDomain^ domain = AppDomain::CreateDomain( "MyDomain", adevidence, domaininfo );
// Write Out the application domain information.
Console::WriteLine( "Host domain: {0}", AppDomain::CurrentDomain->FriendlyName );
Console::WriteLine( "new child domain: {0}", domain->FriendlyName );
Console::WriteLine();
Console::WriteLine( "Application base is: {0}", domain->SetupInformation->ApplicationBase );
AppDomain::Unload( domain );
}
import System.*;
import System.Reflection.*;
import System.Security.Policy.*; //for evidence object
class ADSetupInformation
{
public static void main(String[] args)
{
//Create the application domain setup information.
AppDomainSetup domainInfo = new AppDomainSetup();
domainInfo.set_ApplicationBase(System.Environment.get_CurrentDirectory());
//Create evidence for new appdomain.
Evidence adEvidence = AppDomain.get_CurrentDomain().get_Evidence();
// Create the new application domain using setup information.
AppDomain domain = AppDomain.CreateDomain("MyDomain", adEvidence,
domainInfo);
// Write out the application domain information.
Console.WriteLine("Host domain: "
+ AppDomain.get_CurrentDomain().get_FriendlyName());
Console.WriteLine("new child domain: "
+ domain.get_FriendlyName());
Console.WriteLine();
Console.WriteLine("Application base is: "
+ domain.get_SetupInformation().get_ApplicationBase());
AppDomain.Unload(domain);
} //main
} //ADSetupInformation
.NET Framework 安全性
- FileIOPermission 用于访问路径信息。关联的枚举:PathDiscovery。
平台
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0