AppDomain.GetData Method

Gets the value stored in the current application domain for the specified name.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public Object GetData (
	string name
)
public final Object GetData (
	String name
)
public final function GetData (
	name : String
) : Object

Parameters

name

The name of a predefined application domain property, or the name of an application domain property you have defined.

Return Value

The value of the name property.

Exception typeCondition

ArgumentNullException

name is a null reference (Nothing in Visual Basic).

AppDomainUnloadedException

Operations are attempted on an unloaded application domain.

Use this method to retrieve the value of an entry in an internal cache of name-data pairs that describe properties of this instance of AppDomain.

The cache automatically contains predefined system entries that are inserted when the application domain is created. You can inspect their values with the GetData method, or the equivalent AppDomainSetup properties.

You can insert or modify your own user defined name-data pairs with the SetData method and inspect their values with the GetData method.

The following table describes the name of each predefined system entry and its corresponding AppDomainSetup property.

Value of 'name'

Property

"APPBASE"

ApplicationBase

"LOADER_OPTIMIZATION"

LoaderOptimization

"APP_CONFIG_FILE"

ConfigurationFile

"DYNAMIC_BASE"

DynamicBase

"DEV_PATH"

(no property)

"APP_NAME"

ApplicationName

"PRIVATE_BINPATH"

PrivateBinPath

"BINPATH_PROBE_ONLY"

PrivateBinPathProbe

"SHADOW_COPY_DIRS"

ShadowCopyDirectories

"FORCE_CACHE_INSTALL"

ShadowCopyFiles

"CACHE_BASE"

CachePath

(application specific)

LicenseFile

using System;
using System.Reflection;

class ADGetData 
{

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

		//set predefined system variable application name
		String dataName = "APP_NAME";
		String setappname = "MyApplication";
		currentDomain.SetData(dataName, setappname);

		//Create a new value pair for the appdomain
		String dataValue = "ADVALUE";
		Int32 advalue = 6;
		currentDomain.SetData(dataValue, advalue);

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

		//get system value specified at appdomainsetup
		Console.WriteLine("System value for application name:" + currentDomain.GetData("APP_NAME"));
		
	}
   
	
}

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: