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 |
|---|---|
The localized error message string specified by message. | |
The first permission in the permission set or permission set collection specified by permThatFailed. | |
An empty string. | |
The security permission, permission set, or permission set collection specified by demanded. | |
An empty string. | |
The denied security permission, permission set, or permission set collection specified by deny. | |
The permission, permission set, or permission set collection specified by permitOnly. | |
null. | |
The MethodInfo specified by method. | |
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);
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.