System.Security.Permissions.RegistryPermission Class

Controls the ability to access registry variables. This class cannot be inherited.

See Also: RegistryPermission Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public sealed class RegistryPermission : System.Security.CodeAccessPermission, IBuiltInPermission, IUnrestrictedPermission

Remarks

System.Security.Permissions.RegistryPermission describes protected operations on registry variables. Registry variables should not be stored in memory locations where code without System.Security.Permissions.RegistryPermission can access them. If the registry object is passed to an untrusted caller it can be misused.

The allowed registry access types are defined by System.Security.Permissions.RegistryPermissionAccess. If more than one type of access is desired, they can be combined using the bitwise OR operation as shown in the code sample that follows.

Registry permission is defined in terms of canonical absolute paths; checks should always be made with canonical pathnames. Key access implies access to all values it contains and all variables under it.

Note:

In versions of the .NET Framework before the net_v40_long, you could use the System.Security.CodeAccessPermission.Deny method to prevent inadvertent access to system resources by trusted code. System.Security.CodeAccessPermission.Deny is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see How To: Run Partially Trusted Code in a Sandbox.

Requirements

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0