AppDomain.CurrentDomain Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает текущий домен приложения для текущего объекта Thread.
public:
static property AppDomain ^ CurrentDomain { AppDomain ^ get(); };
public static AppDomain CurrentDomain { get; }
static member CurrentDomain : AppDomain
Public Shared ReadOnly Property CurrentDomain As AppDomain
Значение свойства
Текущий домен приложения.
Примеры
В следующем примере кода создается новый домен приложения. Свойство CurrentDomain используется для получения AppDomain объекта, представляющего текущий домен приложения. Свойство FriendlyName предоставляет имя текущего домена приложения, которое затем отображается в командной строке.
using namespace System;
int main()
{
AppDomain^ root = AppDomain::CurrentDomain;
AppDomainSetup^ setup = gcnew AppDomainSetup();
setup->ApplicationBase =
root->SetupInformation->ApplicationBase + "MyAppSubfolder\\";
AppDomain^ domain = AppDomain::CreateDomain("MyDomain", nullptr, setup);
Console::WriteLine("Application base of {0}:\r\n\t{1}",
root->FriendlyName, root->SetupInformation->ApplicationBase);
Console::WriteLine("Application base of {0}:\r\n\t{1}",
domain->FriendlyName, domain->SetupInformation->ApplicationBase);
AppDomain::Unload(domain);
}
/* This example produces output similar to the following:
Application base of MyApp.exe:
C:\Program Files\MyApp\
Application base of MyDomain:
C:\Program Files\MyApp\MyAppSubfolder\
*/
using System;
class ADSetupInformation
{
static void Main()
{
AppDomain root = AppDomain.CurrentDomain;
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase =
root.SetupInformation.ApplicationBase + @"MyAppSubfolder\";
AppDomain domain = AppDomain.CreateDomain("MyDomain", null, setup);
Console.WriteLine("Application base of {0}:\r\n\t{1}",
root.FriendlyName, root.SetupInformation.ApplicationBase);
Console.WriteLine("Application base of {0}:\r\n\t{1}",
domain.FriendlyName, domain.SetupInformation.ApplicationBase);
AppDomain.Unload(domain);
}
}
/* This example produces output similar to the following:
Application base of MyApp.exe:
C:\Program Files\MyApp\
Application base of MyDomain:
C:\Program Files\MyApp\MyAppSubfolder\
*/
open System
let root = AppDomain.CurrentDomain
let setup = AppDomainSetup()
setup.ApplicationBase <-
root.SetupInformation.ApplicationBase + @"MyAppSubfolder\"
let domain = AppDomain.CreateDomain("MyDomain", null, setup)
printfn $"Application base of {root.FriendlyName}:\r\n\t{root.SetupInformation.ApplicationBase}"
printfn $"Application base of {domain.FriendlyName}:\r\n\t{domain.SetupInformation.ApplicationBase}"
AppDomain.Unload domain
(* This example produces output similar to the following:
Application base of MyApp.exe:
C:\Program Files\MyApp\
Application base of MyDomain:
C:\Program Files\MyApp\MyAppSubfolder\
*)
Class ADSetupInformation
Shared Sub Main()
Dim root As AppDomain = AppDomain.CurrentDomain
Dim setup As New AppDomainSetup()
setup.ApplicationBase = _
root.SetupInformation.ApplicationBase & "MyAppSubfolder\"
Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain", Nothing, setup)
Console.WriteLine("Application base of {0}:" & vbCrLf & vbTab & "{1}", _
root.FriendlyName, root.SetupInformation.ApplicationBase)
Console.WriteLine("Application base of {0}:" & vbCrLf & vbTab & "{1}", _
domain.FriendlyName, domain.SetupInformation.ApplicationBase)
AppDomain.Unload(domain)
End Sub
End Class
' This example produces output similar to the following:
'
'Application base of MyApp.exe:
' C:\Program Files\MyApp\
'Application base of MyDomain:
' C:\Program Files\MyApp\MyAppSubfolder\