When implemented by a subclass of CodeAccessPermission, this method determines whether the current permission object represents the ability to access the resource in the manner specified by the demand argument.
[Visual Basic] Overridable Public Sub CheckDemand( _ ByVal demand As CodeAccessPermission _ ) [C#] public virtual void CheckDemand( CodeAccessPermission demand ); [C++] public: virtual void CheckDemand( CodeAccessPermission* demand ); [JScript] public function CheckDemand( demand : CodeAccessPermission );
Exception Type | Condition |
---|---|
SecurityException | if the demand argument specifies that a resource can be accessed in a way that is not allowed by the current permission object. |
Each code access permission class implements this method. Most developers will probably never need to call this method. It is called by the NGWS runtime during security checks when it compares a permission that has been granted to a component with a permission that is demanded by another component. For example, when a secure library demands that its callers have some permission D, it calls D.Demand(). This causes the runtime to perform a stack walk beginning with the immediate caller of the library. For each stack frame, the runtime calls G.CheckDemand(D), where G is the permission granted to the code associated with the stack frame. If the granted permission, G, satisfies the demand for D, CheckDemand returns. Otherwise, it raises a SecurityException to indicate that the demand for D fails.
Notes to Implementers: The CodeAccessPermission class does not implement this method. If you want your subclass of CodeAccessPermission to be non-abstract, it must override this method.
CodeAccessPermission Class | CodeAccessPermission Members | System.Security Namespace