AppDomain.SetData Method (String, Object, IPermission)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Assigns the specified value to the specified application domain property, with a specified permission to demand of the caller when the property is retrieved.

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

public void SetData(
	string name,
	object data,
	IPermission permission


Type: System.String

The name of a user-defined application domain property to create or change.

Type: System.Object

The value of the property.

Type: System.Security.IPermission

The permission to demand of the caller when the property is retrieved.

Exception Condition

name is null.


name specifies a system-defined property string and permission is not null.

Use this method to insert or modify your own user-defined entries in an internal cache of name/data pairs that describe properties of the application domain. When you insert an entry, you can specify a permission demand to enforce when the entry is retrieved.In addition, you can call this method to set the value of the default timeout interval for evaluating regular expression patterns by supply "REGEX_DEFAULT_MATCH_TIMEOUT" as the value of the name argument and a TimeSpan value that represents the timeout interval as the value of the data argument.

You cannot use this method to assign a security demand to a system-defined property string.

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. A method call that attempts to modify a system entry has no effect; the method does not throw an exception. You can inspect the values of system entries with the GetData method or the equivalent AppDomainSetup properties described in the Remarks section for the GetData method.


requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

.NET Framework
Available since 2.0
Return to top