Mono Class Library: System.Security.CodeAccessPermission Overview | Members

System.Security.CodeAccessPermission.Demand Method

Forces a System.Security.SecurityException if all callers do not have the permission specified by the current instance.

public void Demand ()

Exceptions

TypeReason
System.Security.SecurityException

A caller does not have the permission specified by the current instance.

-or-

A caller has called CodeAccessPermission.Deny for the resource protected by the current instance.

Remarks

The permissions of the code that calls this method are not examined; the check begins from the immediate caller of that code and continues until all callers have been checked, one of the callers invokes CodeAccessPermission.Assert , or a caller has been found that is not granted the demanded permission, in which case a System.Security.SecurityException is thrown.

Note:

CodeAccessPermission.Demand is typically used by shared libraries to ensure that callers have permission to access a resource. For example, a method in a shared library calls CodeAccessPermission.Demand for the necessary System.Security.Permissions.FileIOPermission before performing a file operation requested by the caller.

This method is implemented to support the System.Security.IPermission interface.

Requirements

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