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)

'Declaration
Public Sub New ( _
	message As String, _
	deny As Object, _
	permitOnly As Object, _
	method As MethodInfo, _
	demanded As Object, _
	permThatFailed As IPermission _
)

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

Nothing.

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, _
    CType(sE.FirstPermissionThatFailed, IPermission))


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft