AppDomain.GetData(String) Methode

Definition

Ruft den in der aktuellen Anwendungsdomäne gespeicherten Wert für den angegebenen Namen ab.

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

Parameter

name
String

Der Name einer vordefinierten Anwendungsdomäneneigenschaft oder der Name einer von Ihnen definierten Anwendungsdomäneneigenschaft.

Gibt zurück

Object

Der Wert der name-Eigenschaft oder null, wenn die Eigenschaft nicht vorhanden ist.

Implementiert

Ausnahmen

name ist null.

Der Vorgang wird für eine entladene Anwendungsdomäne ausgeführt.

Beispiele

Im folgenden Beispiel wird eine neue Anwendungsdomäne erstellt, ein systembezogener Wert für die Domäne festgelegt und ein neues Wertpaar für die Domäne hinzugefügt. Im Beispiel wird veranschaulicht, wie Sie die GetData Methode zum Abrufen der Daten aus diesen Wertpaaren verwenden und diese in der Konsole anzeigen.

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

Hinweise

Verwenden Sie diese Methode, um den Wert eines Eintrags in einem internen Cache von Namendatenpaaren abzurufen, die Eigenschaften dieser Instanz AppDomainbeschreiben. Beachten Sie, dass der Vergleich name mit dem Namen der Schlüsselwertpaare Groß-/Kleinschreibung ist.

Der Cache enthält automatisch vordefinierte Systemeinträge, die eingefügt werden, wenn die Anwendungsdomäne erstellt wird. Sie können ihre Werte mit der GetData Methode oder den entsprechenden AppDomainSetup Eigenschaften überprüfen.

Sie können ihre eigenen benutzerdefinierten Namendatenpaare mit der Methode einfügen oder ändern und ihre Werte mit der SetData GetData Methode überprüfen.

In der folgenden Tabelle werden die name einzelnen vordefinierten Systemeinträge und die entsprechende AppDomainSetup Eigenschaft beschrieben.

Wert von "Name" Eigenschaft
"APPBASE" AppDomainSetup.ApplicationBase
"APP_CONFIG_FILE" AppDomainSetup.ConfigurationFile
"APP_LAUNCH_URL" (keine Eigenschaft)

"APP_LAUNCH_URL" stellt die von dem Benutzer angeforderte URL vor einer Umleitung dar. Es ist nur verfügbar, wenn die Anwendung mit einem Browser wie Internet Explorer gestartet wurde. Nicht alle Browser bieten diesen Wert.
"APP_NAME" AppDomainSetup.ApplicationName
"BINPATH_PROBE_ONLY" AppDomainSetup.PrivateBinPathProbe
"CACHE_BASE" AppDomainSetup.CachePath
"CODE_DOWNLOAD_DISABLED" AppDomainSetup.DisallowCodeDownload
"DEV_PATH" (keine Eigenschaft)
"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" oder eine anwendungsspezifische Zeichenfolge AppDomainSetup.LicenseFile
"LOADER_OPTIMIZATION" AppDomainSetup.LoaderOptimization
"LOCATION_URI" (keine Eigenschaft)
"PRIVATE_BINPATH" AppDomainSetup.PrivateBinPath
"REGEX_DEFAULT_MATCH_TIMEOUT" Regex.MatchTimeout

"REGEX_DEFAULT_MATCH_TIMEOUT" ist kein Systemeintrag, und der Wert kann durch Aufrufen der SetData Methode festgelegt werden.
"SHADOW_COPY_DIRS" AppDomainSetup.ShadowCopyDirectories

Gilt für:

Siehe auch