AppDomain.GetData(String) メソッド

定義

現在のアプリケーション ドメイン内に格納されている、指定した名前の値を取得します。

public:
 System::Object ^ GetData(System::String ^ name);
public:
 virtual System::Object ^ GetData(System::String ^ name);
public object? GetData (string name);
public object GetData (string name);
member this.GetData : string -> obj
abstract member GetData : string -> obj
override this.GetData : string -> obj
Public Function GetData (name As String) As Object

パラメーター

name
String

あらかじめ定義されたアプリケーション ドメイン プロパティの名前、または独自に定義したアプリケーション ドメイン プロパティの名前。

戻り値

name プロパティの値。プロパティが存在しない場合は null

実装

例外

namenullです。

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

次の例では、新しいアプリケーション ドメインを作成し、ドメインにシステム指定の値を設定し、ドメインの新しい値ペアを追加します。 次に、 メソッドを使用 GetData してこれらの値ペアからデータを取得し、コンソールに表示する方法を示します。

using namespace System;
using namespace System::Reflection;

int main()
{
   // appdomain setup information
   AppDomain^ currentDomain = AppDomain::CurrentDomain;
   
   //Create a new value pair for the appdomain
   currentDomain->SetData( "ADVALUE", "Example value" );
   
   //get the value specified in the setdata method
   Console::WriteLine( "ADVALUE is: {0}", currentDomain->GetData( "ADVALUE" ) );
   
   //get a system value specified at appdomainsetup
   Console::WriteLine( "System value for loader optimization: {0}", 
      currentDomain->GetData( "LOADER_OPTIMIZATION" ) );
}

/* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
 */
using System;
using System.Reflection;

class ADGetData
{
    public static void Main()
    {
        // appdomain setup information
        AppDomain currentDomain = AppDomain.CurrentDomain;

        //Create a new value pair for the appdomain
        currentDomain.SetData("ADVALUE", "Example value");

        //get the value specified in the setdata method
        Console.WriteLine("ADVALUE is: " + currentDomain.GetData("ADVALUE"));

        //get a system value specified at appdomainsetup
        Console.WriteLine("System value for loader optimization: {0}",
            currentDomain.GetData("LOADER_OPTIMIZATION"));
    }
}

/* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
 */
open System

// appdomain setup information
let currentDomain = AppDomain.CurrentDomain

//Create a new value pair for the appdomain
currentDomain.SetData("ADVALUE", "Example value")

//get the value specified in the setdata method
currentDomain.GetData "ADVALUE"
|> printfn "ADVALUE is: %O"

//get a system value specified at appdomainsetup
currentDomain.GetData "LOADER_OPTIMIZATION"
|> printfn "System value for loader optimization: %O"

(* This code example produces the following output:

ADVALUE is: Example value
System value for loader optimization: NotSpecified
*)
Imports System.Reflection

Class ADGetData   
   
   Public Shared Sub Main()
      ' appdomain setup information
      Dim currentDomain As AppDomain = AppDomain.CurrentDomain
      
      'Create a new value pair for the appdomain
      currentDomain.SetData("ADVALUE", "Example value")
      
      'get the value specified in the setdata method
      Console.WriteLine(("ADVALUE is: " & currentDomain.GetData("ADVALUE")))
      
      'get a system value specified at appdomainsetup
      Console.WriteLine("System value for loader optimization: {0}", _
         currentDomain.GetData("LOADER_OPTIMIZATION"))

   End Sub 
End Class 

' This code example produces the following output:
'
'ADVALUE is: Example value
'System value for loader optimization: NotSpecified

注釈

のこのインスタンスのプロパティを記述する名前とデータのペアの内部キャッシュ内のエントリの値を取得するには、このメソッドを使用します AppDomain。 キーと値のペアの name 名前との比較では、大文字と小文字が区別されることに注意してください。

キャッシュには、アプリケーション ドメインの作成時に挿入される定義済みのシステム エントリが自動的に含まれます。 メソッドまたは同等AppDomainSetupのプロパティを使用してGetData、それらの値を調べることができます。

メソッドを使用して、独自のユーザー定義の名前とデータのペアを SetData 挿入または変更し、 メソッドでその値を GetData 調べることができます。

次の表では、 name 定義済みの各システム エントリとそれに対応する AppDomainSetup プロパティについて説明します。

'name' の値 プロパティ
"APPBASE" AppDomainSetup.ApplicationBase
"APP_CONFIG_FILE" AppDomainSetup.ConfigurationFile
"APP_LAUNCH_URL" (プロパティなし)

"APP_LAUNCH_URL" は、リダイレクトの前にユーザーが最初に要求した URL を表します。 これは、アプリケーションがブラウザーで起動された場合にのみ使用できます。 すべてのブラウザーでこの値が提供されるわけではありません。
"APP_NAME" AppDomainSetup.ApplicationName
"BINPATH_PROBE_ONLY" AppDomainSetup.PrivateBinPathProbe
"CACHE_BASE" AppDomainSetup.CachePath
"CODE_DOWNLOAD_DISABLED" AppDomainSetup.DisallowCodeDownload
"DEV_PATH" (プロパティなし)
"DISALLOW_APP" AppDomainSetup.DisallowPublisherPolicy
"DISALLOW_APP_BASE_PROBING" AppDomainSetup.DisallowApplicationBaseProbing
"DISALLOW_APP_REDIRECTS" AppDomainSetup.DisallowBindingRedirects
"DYNAMIC_BASE" AppDomainSetup.DynamicBase
"FORCE_CACHE_INSTALL" AppDomainSetup.ShadowCopyFiles
"LICENSE_FILE"、またはアプリケーション固有の文字列 AppDomainSetup.LicenseFile
"LOADER_OPTIMIZATION" AppDomainSetup.LoaderOptimization
"LOCATION_URI" (プロパティなし)
"PRIVATE_BINPATH" AppDomainSetup.PrivateBinPath
"REGEX_DEFAULT_MATCH_TIMEOUT" Regex.MatchTimeout

"REGEX_DEFAULT_MATCH_TIMEOUT" はシステム エントリではなく、 メソッドを呼び出すことによって値を SetData 設定できます。
"SHADOW_COPY_DIRS" AppDomainSetup.ShadowCopyDirectories

適用対象

こちらもご覧ください