Asserts that calling code can access the resource identified by the current instance through the code that calls this method, even if callers have not been granted permission to access the resource.
Type Reason System.Security.Permissions.SecurityPermission Requires permission to call CodeAccessPermission.Assert. See System.Security.Permissions.SecurityPermissionFlag.Assertion.
Type Reason System.Security.SecurityException The calling code does not have System.Security.Permissions.SecurityPermissionFlag.Assertion.
Calling CodeAccessPermission.Assert stops the permission check on callers that are after the code performing the assert. An assertion is effective only if the code that calls CodeAccessPermission.Assert passes the security check for the permission that it is asserting.
Note:Even if the callers that are after the code performing the assert do not have the requisite permissions, they can still access resources through the code that calls this method. Because the assertion only applies to the callers of the code performing the assert, a security check for the asserted permission can still fail if the code calling CodeAccessPermission.Assert has not itself been granted that permission.
A call to CodeAccessPermission.Assert is effective until the code containing the call returns to its caller.
Caution: Because calling CodeAccessPermission.Assert removes the requirement that all code be granted permission to access the specified resource, it can open up security vulnerabilities if used incorrectly or inappropriately.
Namespace: System.Security
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0