Language

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。

実装

例外

name は nullです。

アンロードされたアプリケーション ドメインに対して操作が試行されます。

例

次の例では、新しいアプリケーション ドメインを作成し、ドメインにシステム指定の値を設定し、ドメインの新しい値ペアを追加します。 次に、 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とキーと値のペアの名前の比較では、大文字と小文字が区別されることに注意してください。

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

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

適用対象

こちらもご覧ください