Edit

Share via


GacIdentityPermissionAttribute(SecurityAction) Constructor

Definition

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)

Parameters

action
SecurityAction

One of the SecurityAction values.

Exceptions

The action parameter is not a valid SecurityAction value.

Examples

The following code example demonstrates the use of the GacIdentityPermissionAttribute constructor to demand that the calling program be in the global assembly cache. 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

Remarks

The constructor calls the base class to validate the SecurityAction value.

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. Use GacIdentityPermission for imperative security.

Applies to