AppDomain.IsDefaultAppDomain メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
アプリケーション ドメインが、プロセスの既定のアプリケーション ドメインであるかどうかを示す値を返します。
public:
bool IsDefaultAppDomain();
public bool IsDefaultAppDomain ();
member this.IsDefaultAppDomain : unit -> bool
Public Function IsDefaultAppDomain () As Boolean
戻り値
現在の AppDomain オブジェクトがプロセスの既定のアプリケーション ドメインを表す場合は true
。それ以外の場合は false
。
例
次のコード例では、2 つ目のアプリケーション ドメインを作成し、既定のドメインと新しいドメインに関する情報を表示します。
using namespace System;
using namespace System::Reflection;
// This method has the same signature as the CrossAppDomainDelegate,
// so that it can be executed easily in the new application domain.
//
static void ShowDomainInfo()
{
AppDomain^ ad = AppDomain::CurrentDomain;
Console::WriteLine();
Console::WriteLine( L"FriendlyName: {0}", ad->FriendlyName );
Console::WriteLine( L"Id: {0}", ad->Id );
Console::WriteLine( L"IsDefaultAppDomain: {0}", ad->IsDefaultAppDomain() );
}
// The following attribute indicates to the loader that assemblies
// in the global assembly cache should be shared across multiple
// application domains.
//
[LoaderOptimizationAttribute(LoaderOptimization::MultiDomainHost)]
int main()
{
// Show information for the default application domain.
ShowDomainInfo();
// Create a new application domain and display its information.
AppDomain^ newDomain = AppDomain::CreateDomain( L"MyMultiDomain" );
newDomain->DoCallBack( gcnew CrossAppDomainDelegate( ShowDomainInfo ) );
return 0;
}
using System;
using System.Reflection;
public class Example
{
// The following attribute indicates to the loader that assemblies
// in the global assembly cache should be shared across multiple
// application domains.
[LoaderOptimizationAttribute( LoaderOptimization.MultiDomainHost)]
public static void Main()
{
// Show information for the default application domain.
ShowDomainInfo();
// Create a new application domain and display its information.
AppDomain newDomain = AppDomain.CreateDomain("MyMultiDomain");
newDomain.DoCallBack(new CrossAppDomainDelegate(ShowDomainInfo));
}
// This method has the same signature as the CrossAppDomainDelegate,
// so that it can be executed easily in the new application domain.
//
public static void ShowDomainInfo()
{
AppDomain ad = AppDomain.CurrentDomain;
Console.WriteLine();
Console.WriteLine("FriendlyName: {0}", ad.FriendlyName);
Console.WriteLine("Id: {0}", ad.Id);
Console.WriteLine("IsDefaultAppDomain: {0}", ad.IsDefaultAppDomain());
}
}
open System
// This method has the same signature as the CrossAppDomainDelegate,
// so that it can be executed easily in the new application domain.
let showDomainInfo () =
let ad = AppDomain.CurrentDomain
printfn $"\nFriendlyName: {ad.FriendlyName}"
printfn $"Id: {ad.Id}"
printfn $"IsDefaultAppDomain: {ad.IsDefaultAppDomain()}"
// The following attribute indicates to the loader that assemblies
// in the global assembly cache should be shared across multiple
// application domains.
[<LoaderOptimizationAttribute(LoaderOptimization.MultiDomainHost)>]
[<EntryPoint>]
let main _ =
// Show information for the default application domain.
showDomainInfo ()
// Create a new application domain and display its information.
let newDomain = AppDomain.CreateDomain "MyMultiDomain"
newDomain.DoCallBack(CrossAppDomainDelegate showDomainInfo)
0
Imports System.Reflection
Public Class Example
' The following attribute indicates to the loader that assemblies
' in the global assembly cache should be shared across multiple
' application domains.
<LoaderOptimizationAttribute(LoaderOptimization.MultiDomainHost)> _
Public Shared Sub Main()
' Show information for the default application domain.
ShowDomainInfo()
' Create a new application domain and display its information.
Dim newDomain As AppDomain = AppDomain.CreateDomain("MyMultiDomain")
newDomain.DoCallBack(AddressOf ShowDomainInfo)
End Sub
' This method has the same signature as the CrossAppDomainDelegate,
' so that it can be executed easily in the new application domain.
'
Public Shared Sub ShowDomainInfo()
Dim ad As AppDomain = AppDomain.CurrentDomain
Console.WriteLine()
Console.WriteLine("FriendlyName: {0}", ad.FriendlyName)
Console.WriteLine("Id: {0}", ad.Id)
Console.WriteLine("IsDefaultAppDomain: {0}", ad.IsDefaultAppDomain())
End Sub
End Class
注釈
すべてのマネージド プロセスには、既定のアプリケーション ドメインがあります。 既定のドメインで実行が開始されます。