CodeAccessPermission Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Caution
Code Access Security is not supported or honored by the runtime.
Defines the underlying structure of all code access permissions.
public ref class CodeAccessPermission abstract : System::Security::IPermission, System::Security::IStackWalk
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public abstract class CodeAccessPermission : System.Security.IPermission, System.Security.IStackWalk
[System.Serializable]
public abstract class CodeAccessPermission : System.Security.IPermission, System.Security.IStackWalk
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class CodeAccessPermission : System.Security.IPermission, System.Security.IStackWalk
public abstract class CodeAccessPermission : System.Security.IPermission, System.Security.IStackWalk
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type CodeAccessPermission = class
interface IPermission
interface ISecurityEncodable
interface IStackWalk
[<System.Serializable>]
type CodeAccessPermission = class
interface IPermission
interface ISecurityEncodable
interface IStackWalk
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CodeAccessPermission = class
interface IPermission
interface ISecurityEncodable
interface IStackWalk
type CodeAccessPermission = class
interface IPermission
interface ISecurityEncodable
interface IStackWalk
Public MustInherit Class CodeAccessPermission
Implements IPermission, IStackWalk
- Inheritance
-
CodeAccessPermission
- Derived
- Attributes
- Implements
Remarks
Caution
Code Access Security (CAS) has been deprecated across all versions of .NET Framework and .NET. Recent versions of .NET do not honor CAS annotations and produce errors if CAS-related APIs are used. Developers should seek alternative means of accomplishing security tasks.
Code access permissions use a stack walk to ensure that all callers of the code have been granted a permission. If a permission object is null
, it is handled the same as a permission object with the state PermissionState.None.
The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.
Inheritors of the CodeAccessPermission class must be granted full trust to function correctly as permissions extending the security infrastructure. To determine that the inheritors are fully trusted, CodeAccessPermission issues an InheritanceDemand for ControlEvidence = true
and ControlPolicy = true
.
Notes to Implementers
When you inherit from CodeAccessPermission, you must also implement the IUnrestrictedPermission interface.
The following CodeAccessPermission members must be overridden: Copy(), Intersect(IPermission), IsSubsetOf(IPermission), ToXml(), FromXml(SecurityElement), and Union(IPermission).
You must also define a constructor that takes a PermissionState as its only parameter.
You must apply the SerializableAttribute attribute to a class that inherits from CodeAccessPermission.
Constructors
CodeAccessPermission() |
Initializes a new instance of the CodeAccessPermission class. |
Methods
Assert() |
Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. Using Assert() can create security issues. |
Copy() |
When implemented by a derived class, creates and returns an identical copy of the current permission object. |
Demand() |
Forces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance. |
Deny() |
Obsolete.
Obsolete.
Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance. |
Equals(Object) |
Determines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
FromXml(SecurityElement) |
When overridden in a derived class, reconstructs a security object with a specified state from an XML encoding. |
GetHashCode() |
Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
Intersect(IPermission) |
When implemented by a derived class, creates and returns a permission that is the intersection of the current permission and the specified permission. |
IsSubsetOf(IPermission) |
When implemented by a derived class, determines whether the current permission is a subset of the specified permission. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
PermitOnly() |
Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance. |
RevertAll() |
Causes all previous overrides for the current frame to be removed and no longer in effect. |
RevertAssert() |
Causes any previous Assert() for the current frame to be removed and no longer in effect. |
RevertDeny() |
Obsolete.
Obsolete.
Causes any previous Deny() for the current frame to be removed and no longer in effect. |
RevertPermitOnly() |
Causes any previous PermitOnly() for the current frame to be removed and no longer in effect. |
ToString() |
Creates and returns a string representation of the current permission object. |
ToXml() |
When overridden in a derived class, creates an XML encoding of the security object and its current state. |
Union(IPermission) |
When overridden in a derived class, creates a permission that is the union of the current permission and the specified permission. |