The calling code does not have System.Security.Permissions.SecurityPermissionFlag.Assertion.

Description

Calling System.Security.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 System.Security.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 System.Security.CodeAccessPermission.Assert
has not itself been granted that permission.

A call to System.Security.CodeAccessPermission.Assert is effective until the code containing
the call returns to its caller.

Caution:
Because calling System.Security.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.

Exceptions

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

-or-

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

Description

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 System.Security.CodeAccessPermission.Assert
, or a caller has been found that is not granted the
demanded permission, in which case a SecurityException is thrown.

[Note: System.Security.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 System.Security.CodeAccessPermission.Demand for the necessary System.Security.Permissions.FileIOPermission before
performing a file operation requested by the caller.

Exceptions

Description

[Note: This method is implemented to support
the IPermission interface.]

[Behaviors: As described above.]

[Overrides: Override this
method to provide a mechanism for creating an intersection of two IPermission objects that are of the same type and are
derived from CodeAccessPermission
.]

[Usage: The intersection
of two permissions is a permission that secures the resources and operations
secured by both permissions. Specifically, it represents the minimum permission
such that any demand that passes both permissions will also pass their
intersection.]

Exceptions

Description

[Note: This method is implemented to support
the IPermission interface.]

[Behaviors: As described above.]

[Overrides: Override this
method to implement the test for the subset relationship in types derived from
CodeAccessPermission
.]

[Usage: The current
instance is a subset of target if the current instance specifies a set
of accesses to resources that is wholly contained by target. For example, a permission that
represents read access to a file is a subset of a permission that represents
read and write access to the file.

If this method returns true
, the current
instance does not describe a level of access to a set of resources that is
not already described by target.

A String containing the XML
representation of the state of the current instance.

Description

[Note: The XML representation of the current instance is
obtained by first calling System.Security.CodeAccessPermission.ToXml, then calling System.Object.ToString on the
object returned by that
method.

Description

[Behaviors: The object
returned by this method is required to use the XML encoding for the CodeAccessPermission class as defined on the class page. The state of
the current instance is required to be reproducible by invoking System.Security.CodeAccessPermission.FromXml(System.Security.SecurityElement) on an instance
of CodeAccessPermission using the object returned by this
method.]

[Overrides: Override this
method to return an object containing the XML encoding for types derived from
CodeAccessPermission .]

Exceptions

Description

[Note: This method is implemented to support
the IPermission interface.]

[Behaviors: This method
returns a new CodeAccessPermission instance that represents the union of the
current instance and other. If the current instance or other is
unrestricted, returns a CodeAccessPermission instance that is
unrestricted. If other is null
, returns a copy
of the current instance using the System.Security.IPermission.Copy method.]

[Default: If other is not null
, this method
throws a NotSupportedException exception; otherwise,
returns a copy of the current
instance.]

[Overrides: Override this method to provide a mechanism for
creating the union of two IPermission objects that are of the same type and are
derived from CodeAccessPermission .]

[Usage: The result of a call to System.Security.CodeAccessPermission.Union(System.Security.IPermission) is a permission that represents all
of the access to resources represented by both the current instance and
other . Any demand that passes either permission passes their
union.]