Editar

Compartir a través de


StrongNameIdentityPermission Constructors

Definition

Initializes a new instance of the StrongNameIdentityPermission class.

Overloads

StrongNameIdentityPermission(PermissionState)

Initializes a new instance of the StrongNameIdentityPermission class with the specified PermissionState.

StrongNameIdentityPermission(StrongNamePublicKeyBlob, String, Version)

Initializes a new instance of the StrongNameIdentityPermission class for the specified strong name identity.

StrongNameIdentityPermission(PermissionState)

Source:
StrongNameIdentityPermission.cs
Source:
StrongNameIdentityPermission.cs
Source:
StrongNameIdentityPermission.cs

Initializes a new instance of the StrongNameIdentityPermission class with the specified PermissionState.

public:
 StrongNameIdentityPermission(System::Security::Permissions::PermissionState state);
public StrongNameIdentityPermission (System.Security.Permissions.PermissionState state);
new System.Security.Permissions.StrongNameIdentityPermission : System.Security.Permissions.PermissionState -> System.Security.Permissions.StrongNameIdentityPermission
Public Sub New (state As PermissionState)

Parameters

state
PermissionState

One of the PermissionState values.

Exceptions

The state parameter is not a valid value of PermissionState.

Examples

The following code example shows the use of the StrongNameIdentityPermission constructor.

snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
snIdPerm2 = new StrongNameIdentityPermission(PermissionState.None);
snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)

Remarks

Creates either a fully restricted (None) or Unrestricted permission.

Note

In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an Unrestricted permission state value. In the .NET Framework version 2.0 and later, identity permissions can have any permission state value. This means that in version 2.0 and later versions, identity permissions have the same behavior as permissions that implement the IUnrestrictedPermission interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.

In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.

Use this constructor with a permission state value of None to create an identity permission that matches no strong names. If you subsequently set the Name and Version properties, a specific strong name identity can be represented by the permission.

Applies to

StrongNameIdentityPermission(StrongNamePublicKeyBlob, String, Version)

Source:
StrongNameIdentityPermission.cs
Source:
StrongNameIdentityPermission.cs
Source:
StrongNameIdentityPermission.cs

Initializes a new instance of the StrongNameIdentityPermission class for the specified strong name identity.

public:
 StrongNameIdentityPermission(System::Security::Permissions::StrongNamePublicKeyBlob ^ blob, System::String ^ name, Version ^ version);
public StrongNameIdentityPermission (System.Security.Permissions.StrongNamePublicKeyBlob blob, string name, Version version);
new System.Security.Permissions.StrongNameIdentityPermission : System.Security.Permissions.StrongNamePublicKeyBlob * string * Version -> System.Security.Permissions.StrongNameIdentityPermission
Public Sub New (blob As StrongNamePublicKeyBlob, name As String, version As Version)

Parameters

blob
StrongNamePublicKeyBlob

The public key defining the strong name identity namespace.

name
String

The simple name part of the strong name identity. This corresponds to the name of the assembly.

version
Version

The version number of the identity.

Exceptions

The blob parameter is null.

The name parameter is an empty string ("").

Examples

The following code example shows the use of the StrongNameIdentityPermission constructor.

snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
snIdPerm1 = new StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", new Version("1.0.0.0"));
snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))

Remarks

The name and version parameters can be null only when the public key is used to identify the assembly. An empty string ("") should not be used in place of null. If name is an empty string, an ArgumentException is thrown.

For more information on names and version numbers of assemblies, see Strong-named assemblies.

Applies to