public sealed class SecurityPermissionAttribute : CodeAccessSecurityAttribute
Object
Attribute
SecurityAttribute
CodeAccessSecurityAttribute
SecurityPermissionAttribute
mscorlib
BCL
Used to apply a security action and a set of security permissions to program code.
[Note: The security permissions are defined in the SecurityPermissionFlag enumeration and are specified using the System.Security.Permissions.SecurityPermissionAttribute.Flags property.The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. Security attributes are used for declarative security only. For imperative security, use the corresponding permission class, SecurityPermission.
The allowable SecurityPermissionAttribute targets are determined by the SecurityAction passed to the constructor.
]
In the following example, the attribute target is an assembly. The attribute declares that the ability to assert permissions on behalf of callers is the minimum permission required for the assembly to execute.
[assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum, Assertion=true)]
AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple=true, Inherited=false)
System.Security.Permissions Namespace
SecurityPermissionAttribute Constructors
SecurityPermissionAttribute Constructor
SecurityPermissionAttribute Methods
SecurityPermissionAttribute.CreatePermission Method
SecurityPermissionAttribute Properties
public SecurityPermissionAttribute(SecurityAction action);
Constructs and initializes a new instance of the SecurityPermissionAttribute class with the specified SecurityAction value.
- action
- A SecurityAction value.
Exception Type Condition ArgumentException action is not a valid SecurityAction value.
System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace
public override IPermission CreatePermission();
Returns a new SecurityPermission object that contains the security information of the current instance.
A new SecurityPermission object with the security information of the current instance.
[Note: Applications typically do not call this method; it is intended for use by the system.The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. The system uses the object returned by this method to convert the security information of the current instance into the form stored in metadata.
This method overrides System.Security.Permissions.SecurityAttribute.CreatePermission.
]
System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace
public SecurityPermissionFlag Flags { get; set; }
Gets or sets values that define the permissions declared by the current instance.
One or more SecurityPermissionFlag values. To specify multiple values in a set operation, use the bitwise OR operator.
System.Security.Permissions.SecurityPermissionAttribute Class, System.Security.Permissions Namespace