Partilhar via


CodeAccessPermission.demand Method

Definition

Checks the call stack to determine whether the permission that is required to invoke an API has been granted to the calling code.

public:
 void demand();
public void demand ();
member this.demand : unit -> unit
Public Sub demand ()

Remarks

The following code example shows a call to the demand method before the API functionality is executed, to determine whether permission to access the resource that is specified by the data variable has been granted to code that is calling the API.

public static void main(str data) 
{ 
    SysTestCodeAccessPermission p = new SysTestCodeAccessPermission(data); 
    p.demand(); 
    //Add functionality 
}

This code example illustrates a step in the process of protecting an API.

Applies to