GetData Method

AppDomain.GetData Method

Updated: March 2011

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

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

'Declaration
Public Function GetData ( _
	name As String _
) As Object
'Usage
Dim instance As AppDomain 
Dim name As String 
Dim returnValue As Object 

returnValue = instance.GetData(name)

Parameters

name
Type: System.String

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

Return Value

Type: System.Object
The value of the name property, or Nothing if the property does not exist.

Implements

_AppDomain.GetData(String)

ExceptionCondition
ArgumentNullException

name is Nothing.

AppDomainUnloadedException

The operation is 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

"APP_LAUNCH_URL"

(no property)

NoteNote:

"APP_LAUNCH_URL" represents the URL originally requested by the user, before any redirection. It is available only when the application has been launched with a browser such as Internet Explorer. Not all browsers provide this value.

The following code example creates a new application domain, sets a system-provided value for the domain, and adds a new value pair for the domain. The example then demonstrates how to use the GetData method to retrieve the data from these value pairs and display them to the console.

Imports System
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

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

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Date

History

Reason

March 2011

Clarified that Nothing is returned if name does not exist.

Customer feedback.

Community Additions

ADD
Show:
© 2016 Microsoft