BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.SystemException System.Runtime.InteropServices.ComVisible(true)

A exception is thrown when a caller does not have the permissions required to access a resource. The following example instantiates a object that includes a object to allow access to UI objects and the Clipboard and a object to prevent registry access. The call to the method means that these permissions will apply regardless of the permissions assigned to the caller. As a result, the attempt to create a registry key throws a .

code reference: System.SecurityException.Class#1

uses the HRESULT COR_E_SECURITY, which has the value 0x8013150A.

For a list of the initial property values for an instance of the class, see a specific constructor.

The exception that is thrown when a security error is detected.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of the class.

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The localized error message string.

  Initializes a new instance of the class with default properties.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the initial property values for an instance of the class.

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The localized error message string.

  Initializes a new instance of the class with a specified error message.

  The error message that explains the reason for the exception.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor is called during deserialization to reconstitute the exception object transmitted over a stream.

  This constructor sets the following property values based on the information in the parameter:

  Initializes a new instance of the class with serialized data.

  The object that holds the serialized object data.
  The contextual information about the source or destination.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the property. The property returns the same value that is passed into the constructor, or null if the property does not supply the inner exception value to the constructor.

  The following table shows the initial property values for an instance of the class.

  Property

  Value

  The inner exception reference.

  The localized error message string.

  Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.

  The error message that explains the reason for the exception.
  The exception that is the cause of the current exception. If the parameter is not null, the current exception is raised in a catch block that handles the inner exception.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the property values set by this constructor.

  Property

  Value

  The localized error message string specified by .

  The of the permission that failed, specified by .

  Initializes a new instance of the class with a specified error message and the permission type that caused the exception to be thrown.

  The error message that explains the reason for the exception.
  The type of the permission that caused the exception to be thrown.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  The following table shows the property values set by this constructor.

  Property

  Value

  The localized error message string specified by .

  The of the permission that failed, specified by .

  The demanded security permission, permission set, or permission set collection that failed.

  Initializes a new instance of the class with a specified error message, the permission type that caused the exception to be thrown, and the permission state.

  The error message that explains the reason for the exception.
  The type of the permission that caused the exception to be thrown.
  The state of the permission that caused the exception to be thrown.
- Constructor
  2.0.0.0
  4.0.0.0

  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 .

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

  An empty string.

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

  An empty string.

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

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

  null.

  The specified by .

  .

  An empty string.

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

  The error message that explains the reason for the exception.
  The denied permission or permission set.
  The permit-only permission or permission set.
  A that identifies the method that encountered the exception.
  The demanded permission, permission set, or permission set collection.
  An that identifies the permission that failed.
- Constructor
  2.0.0.0
  4.0.0.0

  Use this constructor to throw an exception when the grant set caused the failure of the demand.

  The following table shows the property values set by this constructor.

  Property

  Value

  The localized error message string specified by .

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

  The specified by .

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

  The specified by .

  An empty string.

  An empty string.

  The specified by .

  The specified by .

  The value from the specified by .

  The URL from the specified by .

  Initializes a new instance of the class for an exception caused by an insufficient grant set.

  The error message that explains the reason for the exception.
  An that specifies the name of the assembly that caused the exception.
  A that represents the permissions granted the assembly.
  A that represents the refused permission or permission set.
  A that represents the method that encountered the exception.
  One of the values.
  The demanded permission, permission set, or permission set collection.
  An that represents the permission that failed.
  The for the assembly that caused the exception.
- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Security.Permissions.SecurityAction To be added.

  The 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 or , 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 property contains the security action that caused the exception to be thrown.

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

  Security action

  Description

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

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

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

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

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

  Gets or sets the security action that caused the exception.

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Object To be added.

  In the case of a returned permission set or permission set collection, the returned object contains all the demanded permissions, one or more of which caused the failure.

  Gets or sets the demanded security permission, permission set, or permission set collection that failed.

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Object To be added.

  This property contains the denied permission, permission set, or permission set collection that caused the security check to fail. It is null for exceptions that are not caused by a Deny. The property is of type because it can contain a permission, a permission set, or a permission set collection. To test the run-time type of this property, you can use the method or a specific language operator, such as the is operator in C# or the TypeOf operator in Visual Basic.

  Gets or sets the denied security permission, permission set, or permission set collection that caused a demand to fail.

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Reflection.AssemblyName To be added.

  This property contains an object that identifies the assembly that caused the security check to fail.

  This property is not populated when a security exception occurs in a or stack frame, because the assembly issuing the or security action is not the assembly that failed the stack walk. In these cases, the security exception is created with a constructor that does not require an assembly name, granted set information, or refused set information.

  Gets or sets information about the failed assembly.

- Property
  2.0.0.0
  4.0.0.0
  System.Security.IPermission To be added.

  If the demanded object is a permission set or permission set collection, the represents only the first permission that caused the exception. Additional permissions in the set or collection can also cause a demand failure.

  Gets or sets the first permission in a permission set or permission set collection that failed the demand.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  GetObjectData sets a with all the exception object data targeted for serialization. During deserialization, the exception is reconstituted from the SerializationInfo transmitted over the stream.

  Sets the with information about the .

  The that holds the serialized object data about the exception being thrown. The that contains contextual information about the source or destination.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added.

  This property might not contain relevant data in security exceptions other than exceptions involving checks for the .

  Gets or sets the granted permission set of the assembly that caused the .

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Reflection.MethodInfo To be added.

  This property contains one of the following:

  Information about the method that the failed assembly was executing when the security check that triggered the exception occurred.

  Information about the method that placed either a or security action on the call stack, in the case of a failure due to a or .

  null, in the case of a failure that is impossible to attribute to a specific method.

  The object provides the method name, class name, and assembly name information that uniquely identifies the method.

  Gets or sets the information about the method associated with the exception.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added. To be added.

  Gets or sets the state of the permission that threw the exception.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Type To be added. To be added.

  Gets or sets the type of the permission that failed.

- Property
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.ComVisible(false)
  System.Object To be added.

  The property represents the permitted permission, permission set, or permission set collection contained in the stack frame that caused the security exception. For instance, when a security exception occurs because of a failure, the permitted permission appears in this property and the demanded is contained in the property.

  This property is of type because permissions, permission sets, or permission set collections can all be demanded and is their common base class. To test the run-time type of this property, you can use the method or a specific language operator, such as the is operator in C# or the TypeOf operator in Visual Basic.

  Gets or sets the permission, permission set, or permission set collection that is part of the permit-only stack frame that caused a security check to fail.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added.

  This property might not contain relevant data in security exceptions other than exceptions involving checks for the .

  Gets or sets the refused permission set of the assembly that caused the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The method returns the full description of the .

  Returns a representation of the current .

  A string representation of the current .

- Property
  2.0.0.0
  4.0.0.0
  System.String To be added. To be added.

  Gets or sets the URL of the assembly that caused the exception.

- Property
  2.0.0.0
  4.0.0.0
  System.Security.SecurityZone To be added. To be added.

  Gets or sets the zone of the assembly that caused the exception.

0