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.
For more information on inheritance demands, see Inheritance Demands.
Notes to Inheritors
When you inherit from CodeAccessPermission, you must also implement the IUnrestrictedPermission interface.
The following CodeAccessPermission members must be overridden: Copy, Intersect, IsSubsetOf, ToXml, FromXml, and Union.
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.