Export (0) Print
Expand All

SecurityException::Action Property

Gets or sets the security action that caused the exception.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(false)]
public:
property SecurityAction Action {
	SecurityAction get ();
	void set (SecurityAction value);
}

Property Value

Type: System.Security.Permissions::SecurityAction
One of the SecurityAction values.

The Action property contains the security action that caused the security check failure. Many of the security actions can cause a security exception to be thrown. For example, a demand on a permission set checks that all callers on the call stack have the necessary permissions in the permission set. If any caller on the call stack lacks a required permission, the security check fails. Alternatively, a method in the call chain can modify the outcome of the stack walk by placing a stack walk modifier, such as Deny or PermitOnly, on the stack to limit the allowed permissions. For example, a method on the call stack might deny all of its callers a set of permissions named PSET1, such that any demand for a permission that is part of PSET1 fails for those callers. The Action property contains the security action that caused the exception to be thrown.

SecurityAction is an enumeration in the SecurityAction namespace that provides the security action value for the Action property. Typically this property contains one of the values shown in the following table.

Security action

Description

Demand

A full stack walk failed due to a demand made against the assembly identified by the FailedAssemblyInfo property.

LinkDemand

A link demand against the assembly identified by the FailedAssemblyInfo property failed.

InheritanceDemand

An assembly identified by the FailedAssemblyInfo property failed to meet an inheritance demand.

PermitOnly

A demanded permission did not match any permission in the PermitOnly permission set. The method that placed the PermitOnly on the call stack is identified by the Method property.

Deny

A demanded permission matched a permission in the deny permission set on the call stack. The method that placed the Deny on the call stack is identified by the Method property.

The following code example shows the use of the Action property to display the action that caused the exception. This code example is part of a larger example provided for the SecurityException class.

Display("The security action is: {0}",
    exception->Action);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft