GacIdentityPermissionAttribute(SecurityAction) 构造函数
定义
使用指定的 SecurityAction 值初始化 GacIdentityPermissionAttribute 类的新实例。Initializes a new instance of the GacIdentityPermissionAttribute class with the specified SecurityAction value.
public:
GacIdentityPermissionAttribute(System::Security::Permissions::SecurityAction action);
public GacIdentityPermissionAttribute (System.Security.Permissions.SecurityAction action);
new System.Security.Permissions.GacIdentityPermissionAttribute : System.Security.Permissions.SecurityAction -> System.Security.Permissions.GacIdentityPermissionAttribute
Public Sub New (action As SecurityAction)
参数
- action
- SecurityAction
SecurityAction 值之一。One of the SecurityAction values.
例外
action 参数不是有效的 SecurityAction 值。The action parameter is not a valid SecurityAction value.
示例
下面的代码示例演示如何使用 GacIdentityPermissionAttribute 构造函数来要求调用程序位于全局程序集缓存中。The following code example demonstrates the use of the GacIdentityPermissionAttribute constructor to demand that the calling program be in the global assembly cache. 此示例是为类提供的更大示例的一部分 GacIdentityPermissionAttribute 。This example is part of a larger example provided for the GacIdentityPermissionAttribute class.
// Demand that the calling program be in the global assembly cache.
[GacIdentityPermissionAttribute(SecurityAction::Demand)]
public ref class Class1
// Demand that the calling program be in the global assembly cache.
[GacIdentityPermissionAttribute(SecurityAction.Demand)]
public class Class1
' Demand that the calling program be in the global assembly cache.
<GacIdentityPermissionAttribute(SecurityAction.Demand)> _
Public Class Class1
注解
构造函数调用基类来验证 SecurityAction 值。The constructor calls the base class to validate the SecurityAction value.
此构造函数将 SecurityAction (例如, Demand) 与一起使用 GacIdentityPermission 。This constructor associates a SecurityAction (for example, Demand) with the GacIdentityPermission.
安全特性声明的安全信息存储在属性目标的元数据中,由系统在运行时进行访问。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. 用于 GacIdentityPermission 命令性安全。Use GacIdentityPermission for imperative security.