SecurityException Constructor (String, Object, Object, MethodInfo, Object, IPermission)

Initializes a new instance of the SecurityException class for an exception caused by a Deny on the stack.

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

public SecurityException(
	string message,
	Object deny,
	Object permitOnly,
	MethodInfo method,
	Object demanded,
	IPermission permThatFailed
)

Parameters

message
Type: System.String

The error message that explains the reason for the exception.

deny
Type: System.Object

The denied permission or permission set.

permitOnly
Type: System.Object

The permit-only permission or permission set.

method
Type: System.Reflection.MethodInfo

A MethodInfo that identifies the method that encountered the exception.

demanded
Type: System.Object

The demanded permission, permission set, or permission set collection.

permThatFailed
Type: System.Security.IPermission

An IPermission that identifies the permission that failed.

Use this constructor if a frame that contains a Deny caused the demand failure. The following table shows the property values set by this constructor.

Property

Value

Message

The localized error message string specified by message.

FirstPermissionThatFailed

The first permission in the permission set or permission set collection specified by permThatFailed.

GrantedSet

An empty string.

Demanded

The security permission, permission set, or permission set collection specified by demanded.

RefusedSet

An empty string.

DenySetInstance

The denied security permission, permission set, or permission set collection specified by deny.

PermitOnlySetInstance

The permission, permission set, or permission set collection specified by permitOnly.

FailedAssemblyInfo

null.

Method

The MethodInfo specified by method.

Zone

NoZone.

Url

An empty string.

The following code example shows the use of the SecurityException(String, Object, Object, MethodInfo, Object, IPermission) constructor.

//Demonstrate the SecurityException constructor by  
// throwing the exception again.
Display("Rethrowing the exception thrown as a result of a " + 
    "PermitOnly security action.");
throw new SecurityException(sE.Message, sE.DenySetInstance, 
    sE.PermitOnlySetInstance, sE.Method, sE.Demanded, 
    (IPermission)sE.FirstPermissionThatFailed);

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft