Share via


CodeAccessPermission.revertAssert Method

Definition

Causes a previous call to the CodeAccessPermission.assert and CodeAccessPermission::assertMultiple methods to be removed and no longer in effect.

public:
 static void revertAssert();
public static void revertAssert ();
static member revertAssert : unit -> unit
Public Shared Sub revertAssert ()

Remarks

When you have multiple calls to the assert method in the same calling code, you must call the revertAssert method between each call. Otherwise, the Infolog displays an error when you execute the code. When you call the assert method only one time, or when you call the CodeAccessPermission::assertMultiple method, we recommend that you still call the revertAssert method after you invoke the protected API to limit the scope of the assert.

The following code example shows a call to the CodeAccessPermission::revertAssert method after the user calls the CodeAccessPermission.assert method and the AsciiIo class that is protected by a permission.

server static void main(Args args) 
{ 
    FileIoPermission _perm; 
    AsciiIo a; 
    _perm = new FileIoPermission("c:\File.txt",'r'); 
    _perm.assert(); 
    //invoke protected API 
    a = new AsciiIo("c:\File.txt",'r'); 
    // Optionally call revertAssert() to limit scope of assert. 
    CodeAccessPermission::revertAssert(); 
}

Applies to