AppDomain.SetData メソッド

定義

アプリケーション ドメイン プロパティに値を代入します。

オーバーロード

SetData(String, Object)

指定したアプリケーション ドメイン プロパティに、指定した値を割り当てます。

SetData(String, Object, IPermission)

アプリケーション ドメインの特定のプロパティに対し、指定された値を代入します。プロパティの取得時に呼び出し元に要求するアクセス許可を引数として受け取ります。

SetData(String, Object)

指定したアプリケーション ドメイン プロパティに、指定した値を割り当てます。

public:
 void SetData(System::String ^ name, System::Object ^ data);
public:
 virtual void SetData(System::String ^ name, System::Object ^ data);
public void SetData (string name, object? data);
public void SetData (string name, object data);
[System.Security.SecurityCritical]
public void SetData (string name, object data);
member this.SetData : string * obj -> unit
abstract member SetData : string * obj -> unit
override this.SetData : string * obj -> unit
[<System.Security.SecurityCritical>]
abstract member SetData : string * obj -> unit
override this.SetData : string * obj -> unit
Public Sub SetData (name As String, data As Object)

パラメーター

name
String

作成または変更の対象となるユーザー定義アプリケーション ドメイン プロパティの名前。

data
Object

プロパティの値。

実装

属性

例外

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

次の例では、メソッドを使用 SetData(String, Object) して新しい値ペアを作成する方法を示します。 次に、このメソッドを 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値を変更します。

キャッシュには、アプリケーション ドメインの作成時に挿入される定義済みのシステム エントリが自動的に含まれます。 このメソッドを使用してシステム エントリを挿入または変更することはできません。 システム エントリの変更を試みるメソッド呼び出しには影響はありません。メソッドは例外をスローしません。 メソッドを使用GetDataしてシステム エントリの値を調べたり、で説明されているGetData同等AppDomainSetupのプロパティを調べたりすることができます。

このメソッドを呼び出して、引数の値として "REGEX_DEFAULT_MATCH_TIMEOUT" を指定しTimeSpan、タイムアウト間隔を引数のname値として表す値を指定することで、正規表現パターンを評価するための既定のタイムアウト間隔の値をdata設定できます。 また、このメソッドを使用して独自のユーザー定義の名前とデータのペアを挿入または変更し、メソッドでその値を GetData 検査することもできます。

こちらもご覧ください

適用対象

SetData(String, Object, IPermission)

アプリケーション ドメインの特定のプロパティに対し、指定された値を代入します。プロパティの取得時に呼び出し元に要求するアクセス許可を引数として受け取ります。

public:
 void SetData(System::String ^ name, System::Object ^ data, System::Security::IPermission ^ permission);
public void SetData (string name, object data, System.Security.IPermission permission);
[System.Security.SecurityCritical]
public void SetData (string name, object data, System.Security.IPermission permission);
member this.SetData : string * obj * System.Security.IPermission -> unit
[<System.Security.SecurityCritical>]
member this.SetData : string * obj * System.Security.IPermission -> unit
Public Sub SetData (name As String, data As Object, permission As IPermission)

パラメーター

name
String

作成または変更の対象となるユーザー定義アプリケーション ドメイン プロパティの名前。

data
Object

プロパティの値。

permission
IPermission

プロパティの取得時に呼び出し元に要求するアクセス許可。

属性

例外

namenullです。

name にシステム定義のプロパティ文字列が指定されているにもかかわらず、permissionnull です。

注釈

アプリケーション ドメインのプロパティを記述する名前とデータのペアの内部キャッシュに、独自のユーザー定義エントリを挿入または変更するには、このメソッドを使用します。 エントリを挿入するときに、エントリの取得時に適用するアクセス許可の要求を指定できます。さらに、このメソッドを呼び出して、引数の値として "REGEX_DEFAULT_MATCH_TIMEOUT" を指定しTimeSpan、タイムアウト間隔を引数のname値として表す値を指定することで、正規表現パターンを評価するための既定のタイムアウト間隔の値をdata設定できます。

このメソッドを使用して、システム定義のプロパティ文字列にセキュリティ要求を割り当てることはできません。

キャッシュには、アプリケーション ドメインの作成時に挿入される定義済みのシステム エントリが自動的に含まれます。 このメソッドを使用してシステム エントリを挿入または変更することはできません。 システム エントリの変更を試みるメソッド呼び出しには影響はありません。メソッドは例外をスローしません。 メソッドまたはメソッドの「解説」セクションで説明されている同等AppDomainSetupのプロパティを使用して、システム エントリGetDataの値をGetData調べることができます。

適用対象