Causes any PermissionSet.Demand that passes through the calling code for a permission that has an intersection with a permission of a type contained in the current System.Security.PermissionSet to fail.
Type Reason System.Security.SecurityException A previous call to Deny has already restricted the permissions for the current stack frame.
This method prevents callers higher in the call stack from accessing the protected resource through the code that calls this method, even if those callers have been granted permission to access it. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.
PermissionSet.Deny can limit the liability of the programmer or help prevent accidental security vulnerabilities because it helps prevent the method that calls PermissionSet.Deny from being used to access the resource protected by the denied permission. If a method calls PermissionSet.Deny on a permission, and if a PermissionSet.Demand for that permission is invoked by a caller lower in the call stack, that security check fails when it reaches the PermissionSet.Deny.
PermissionSet.Deny is ignored for a permission that is not granted because a demand for that permission cannot succeed.