SecurityPermissionAttribute SecurityPermissionAttribute SecurityPermissionAttribute SecurityPermissionAttribute Class

定义

警告

此 API 现已过时。

允许对要使用声明性安全应用到代码中的 SecurityPermission 执行安全操作。Allows security actions for SecurityPermission to be applied to code using declarative security. 此类不能被继承。This class cannot be inherited.

public ref class SecurityPermissionAttribute sealed : System::Security::Permissions::CodeAccessSecurityAttribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Constructor | System.AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=true, Inherited=false)]
[System.Obsolete("CAS support is not available with Silverlight applications.")]
[System.Serializable]
public sealed class SecurityPermissionAttribute : System.Security.Permissions.CodeAccessSecurityAttribute
type SecurityPermissionAttribute = class
    inherit CodeAccessSecurityAttribute
Public NotInheritable Class SecurityPermissionAttribute
Inherits CodeAccessSecurityAttribute
继承
属性

注解

声明是允许的范围取决于SecurityAction的使用。The scope of the declaration that is allowed depends on the SecurityAction that is used.

声明的安全特性的安全信息的属性目标的元数据中的存储,以及在运行时访问系统。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 only for declarative security. 对于命令性安全,使用相应的权限类。For imperative security, use the corresponding permission class.

当你使用SecurityPermissionAttribute类中,按照与所请求的权限的安全操作。When you use the SecurityPermissionAttribute class, follow the security action with the permission(s) that are being requested. 可以请求,如中所定义的每个安全权限SecurityPermissionFlag枚举中具有相应属性SecurityPermissionAttribute类。Each security permission that can be requested, as defined in the SecurityPermissionFlag enumeration, has a corresponding property in the SecurityPermissionAttribute class. 例如,需要访问非托管的代码的能力,语句后执行按需正在请求,按如下所示的属性设置: SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode=true)For example, to demand the ability to access unmanaged code, follow the demand statement with the property setting that is being requested, as follows: SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode=true).

备注

等效的异常SecurityPermissionFlag枚举并SecurityPermissionAttribute属性是AllFlags枚举值由Unrestricted属性 (继承自SecurityAttribute类)。An exception to the equivalence between the SecurityPermissionFlag enumeration and the SecurityPermissionAttribute properties is that the AllFlags enumeration value is represented by the Unrestricted property (inherited from the SecurityAttribute class). 若要要求所有安全权限,请指定Unrestricted=trueTo demand all security permissions, specify Unrestricted=true.

构造函数

SecurityPermissionAttribute(SecurityAction) SecurityPermissionAttribute(SecurityAction) SecurityPermissionAttribute(SecurityAction) SecurityPermissionAttribute(SecurityAction)

使用指定的 SecurityPermissionAttribute 初始化 SecurityAction 类的新实例。Initializes a new instance of the SecurityPermissionAttribute class with the specified SecurityAction.

属性

Action Action Action Action

获取或设置安全性操作。Gets or sets a security action.

(Inherited from SecurityAttribute)
Assertion Assertion Assertion Assertion

获取或设置一个值,该值指示是否已声明以下要断言的权限:所有此代码的调用方具有此操作的所需权限。Gets or sets a value indicating whether permission to assert that all this code's callers have the requisite permission for the operation is declared.

BindingRedirects BindingRedirects BindingRedirects BindingRedirects

获取或设置一个值,该值表示代码是否具有在应用程序配置文件中执行绑定重定向的权限。Gets or sets a value that indicates whether code has permission to perform binding redirection in the application configuration file.

ControlAppDomain ControlAppDomain ControlAppDomain ControlAppDomain

获取或设置一个值,该值指示是否声明了操作 AppDomain 的权限。Gets or sets a value indicating whether permission to manipulate AppDomain is declared.

ControlDomainPolicy ControlDomainPolicy ControlDomainPolicy ControlDomainPolicy

获取或设置一个值,该值指示是否声明改变或操作域安全策略的权限。Gets or sets a value indicating whether permission to alter or manipulate domain security policy is declared.

ControlEvidence ControlEvidence ControlEvidence ControlEvidence

获取或设置一个值,该值指示是否声明了改变或操作证据的权限。Gets or sets a value indicating whether permission to alter or manipulate evidence is declared.

ControlPolicy ControlPolicy ControlPolicy ControlPolicy

获取或设置一个值,该值指示是否声明了查看和操作安全策略的权限。Gets or sets a value indicating whether permission to view and manipulate security policy is declared.

ControlPrincipal ControlPrincipal ControlPrincipal ControlPrincipal

获取或设置一个值,该值指示是否声明了操作当前主体的权限。Gets or sets a value indicating whether permission to manipulate the current principal is declared.

ControlThread ControlThread ControlThread ControlThread

获取或设置一个值,该值指示是否声明了操作线程的权限。Gets or sets a value indicating whether permission to manipulate threads is declared.

Execution Execution Execution Execution

获取或设置一个值,该值指示是否声明了执行代码的权限。Gets or sets a value indicating whether permission to execute code is declared.

Flags Flags Flags Flags

获取或设置组成 SecurityPermission 权限的所有权限标志。Gets or sets all permission flags comprising the SecurityPermission permissions.

Infrastructure Infrastructure Infrastructure Infrastructure

获取或设置一个值,该值指示代码是否可以插入公共语言运行时结构,例如添加远程处理上下文接收器 (Remoting Context Sink)、Envoy 接收器 (Envoy Sink) 和动态接收器 (Dynamic Sink)。Gets or sets a value indicating whether code can plug into the common language runtime infrastructure, such as adding Remoting Context Sinks, Envoy Sinks and Dynamic Sinks.

RemotingConfiguration RemotingConfiguration RemotingConfiguration RemotingConfiguration

获取或设置一个值,该值指示代码是否可以配置远程处理类型和信道。Gets or sets a value indicating whether code can configure remoting types and channels.

SerializationFormatter SerializationFormatter SerializationFormatter SerializationFormatter

获取或设置一个值,该值指示代码是否可以使用序列化格式化程序来序列化或反序列化对象。Gets or sets a value indicating whether code can use a serialization formatter to serialize or deserialize an object.

SkipVerification SkipVerification SkipVerification SkipVerification

获取或设置一个值,该值指示是否声明了跳过代码验证的权限。Gets or sets a value indicating whether permission to bypass code verification is declared.

TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
UnmanagedCode UnmanagedCode UnmanagedCode UnmanagedCode

获取或设置一个值,该值指示是否声明了调用非托管代码的权限。Gets or sets a value indicating whether permission to call unmanaged code is declared.

Unrestricted Unrestricted Unrestricted Unrestricted

获取或设置一个值,该值指示是否声明了对受该特性保护的资源有完全(无限制的)权限。Gets or sets a value indicating whether full (unrestricted) permission to the resource protected by the attribute is declared.

(Inherited from SecurityAttribute)

方法

CreatePermission() CreatePermission() CreatePermission() CreatePermission()

创建并返回一个新的 SecurityPermissionCreates and returns a new SecurityPermission.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

适用于

另请参阅