AppDomain.SetData Method (String, Object)
Assembly: mscorlib (in mscorlib.dll)
Use this method to insert an entry, or modify 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 cannot insert or modify system entries with this method. You can inspect their values with the GetData method, or the equivalent AppDomainSetup properties described in GetData.
You can insert or modify your own user defined name-data pairs with this method and inspect their values with the GetData method.
The following example demonstrates how to use the SetData(String,Object) method to create a new value pair. The example then uses the GetData method to retrieve the value, and displays it to the console.
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 */
- SecurityPermission for the ability to create and manipulate an application domain. Associated enumeration: SecurityPermissionFlag.ControlAppDomain. Security action: LinkDemand.
- FileIOPermission for access to the information in a path. Associated enumeration: FileIOPermissionAccess.PathDiscovery.
Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.