System.Security.PermissionSet.Demand Method

Forces a System.Security.SecurityException at run time if all callers higher in the call stack have not been granted the permissions specified by the current instance.

Syntax

public void Demand ()

Exceptions

TypeReason
System.Security.SecurityExceptionA caller does not have the permission specified by the current instance.

Remarks

Use PermissionSet.Demand on a System.Security.PermissionSet to ensure that all callers have all permissions in the set with one operation.

The permissions of the code that calls this method are not examined; the check begins from the immediate caller of that code and proceeds up the stack. 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.Demand succeeds only if no System.Security.SecurityException is thrown.

If the System.Security.PermissionSet contains permissions that do not inherit from System.Security.CodeAccessPermission, the Demand methods of those permissions are called as well.

Requirements

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