英語で読む

次の方法で共有


AppDomain.ToString メソッド

定義

アプリケーション ドメインの表示名とコンテキスト ポリシーを含む文字列形式を取得します。

C#
public override string ToString ();

戻り値

String

アプリケーション ドメインの表示名であるリテラル文字列 "Name:" と、コンテキスト ポリシーの文字列形式または "There are no context policies." という文字列のどちらかを連結した文字列。

実装

例外

現在の AppDomain によって表されるアプリケーション ドメインは既にアンロードされています。

次のコード例では、メソッドの戻り値を ToString 表示します。

C#
using System;
using System.Reflection;
using System.Security.Policy;
class ADSetup
{
    public static void Main()
    {
        // Create application domain setup information
        AppDomainSetup domaininfo = new AppDomainSetup();
        
        //Create evidence for the new appdomain from evidence of the current application domain
        Evidence adevidence = AppDomain.CurrentDomain.Evidence;

        // Create appdomain
        AppDomain domain = AppDomain.CreateDomain("MyDomain", adevidence, domaininfo);

        // Write out application domain information
        Console.WriteLine("Host domain: " + AppDomain.CurrentDomain.FriendlyName);
        Console.WriteLine("child domain: " + domain.FriendlyName);
        Console.WriteLine("child domain name using ToString:" + domain.ToString());
        Console.WriteLine();
        
        AppDomain.Unload(domain);
    }
}

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1