英語で読む

次の方法で共有


AppDomain.FriendlyName プロパティ

定義

アプリケーション ドメインの表示名を取得します。

C#
public string FriendlyName { get; }

プロパティ値

String

アプリケーション ドメインの表示名。

実装

例外

アンロードされたアプリケーション ドメインで操作しようとします。

次のコード例では、プロパティを FriendlyName 使用して、現在のアプリケーション ドメインのフレンドリ名を取得します。 既定のアプリケーション ドメインの場合、フレンドリ名はアプリケーションの実行可能ファイルの名前です。 コード例では、アプリケーション ドメインに関する追加情報も表示されます。

C#
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\
 */

注釈

既定のアプリケーション ドメインのフレンドリ名は、プロセス実行可能ファイルのファイル名です。 たとえば、プロセスの開始に使用される実行可能ファイルが 、"c:\MyAppDirectory\MyAssembly.exe"既定のアプリケーション ドメインのフレンドリ名である場合、"MyAssembly.exe"

適用対象

製品 バージョン
.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