This documentation is archived and is not being maintained.

StrongNameIdentityPermissionAttribute Class

Allows security actions for StrongNameIdentityPermission to be applied to code using declarative security. This class cannot be inherited.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

[SerializableAttribute] 
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple=true, Inherited=false)] 
[ComVisibleAttribute(true)] 
public sealed class StrongNameIdentityPermissionAttribute : CodeAccessSecurityAttribute
/** @attribute SerializableAttribute() */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple=true, Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class StrongNameIdentityPermissionAttribute extends CodeAccessSecurityAttribute
SerializableAttribute 
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple=true, Inherited=false) 
ComVisibleAttribute(true) 
public final class StrongNameIdentityPermissionAttribute extends CodeAccessSecurityAttribute
Not applicable.

NoteImportant:

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, 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.

The scope of the declaration that is allowed depends on the SecurityAction that is used.

The key strings for this attribute can be attained by running secutil.exe. For more information, see [<topic://cpgrfsecutiltoolsecutilexe>].

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.

The StrongNameIdentityPermissionAttribute attribute can be used to define strong-name requirements for access to public members at the assembly level. In the .NET Framework version 2.0, you can also use the InternalsVisibleToAttribute attribute to specify that all nonpublic types in that assembly are visible to another assembly. For more information, see Friend Assemblies (C# Programmer's Reference) or Friend Assemblies (Visual Basic).

The following example of a declarative attribute shows the correct way to request StrongNameIdentityPermission and states that you must have at least this permission to run your code. Code will only execute if signed with a strong name using the private key counterpart of the specified public key. Since Name and Version are not specified, this attribute will match any name and version.

[assembly:StrongNameIdentityPermissionAttribute(SecurityAction.RequestMinimum, 
 PublicKey="00240000048000009400000006020000002400005253413100040000010001005" +
 "38a4a19382e9429cf516dcf1399facdccca092a06442efaf9ecaca33457be26ee0073c6bde5" +
 "1fe0873666a62459581669b510ae1e84bef6bcb1aff7957237279d8b7e0e25b71ad39df3684" +
 "5b7db60382c8eb73f289823578d33c09e48d0d2f90ed4541e1438008142ef714bfe604c41a4" +
 "957a4f6e6ab36b9715ec57625904c6")]
 //In C#, you must specify that you are using the assembly scope when making a request.

/** @assembly StrongNameIdentityPermissionAttribute(SecurityAction.
    RequestMinimum, PublicKey =
    "00240000048000009400000006020000002400005253413100040000010001005" 
    + "38a4a19382e9429cf516dcf1399facdccca092a06442efaf9ecaca33457be26ee0073c6bde5" 
    + "1fe0873666a62459581669b510ae1e84bef6bcb1aff7957237279d8b7e0e25b71ad39df3684" 
    + "5b7db60382c8eb73f289823578d33c09e48d0d2f90ed4541e1438008142ef714bfe604c41a4" 
    + "957a4f6e6ab36b9715ec57625904c6")
 */
// In VJ#, you must specify that you are using the assembly scope when making 
// a request.

The following example shows how to demand that the calling code has StrongNameIdentityPermission. Code will only execute if signed with a strong name using the private key counterpart of the specified public key

[StrongNameIdentityPermissionAttribute(SecurityAction.Demand, 
 PublicKey="00240000048000009400000006020000002400005253413100040000010001005" +
 "38a4a19382e9429cf516dcf1399facdccca092a06442efaf9ecaca33457be26ee0073c6bde5" +
 "1fe0873666a62459581669b510ae1e84bef6bcb1aff7957237279d8b7e0e25b71ad39df3684" +
 "5b7db60382c8eb73f289823578d33c09e48d0d2f90ed4541e1438008142ef714bfe604c41a4" +
 "957a4f6e6ab36b9715ec57625904c6")]

/** @attribute StrongNameIdentityPermissionAttribute(SecurityAction.Demand,
    PublicKey = "00240000048000009400000006020000002400005253413100040000010001005"
    + "38a4a19382e9429cf516dcf1399facdccca092a06442efaf9ecaca33457be26ee0073c6bde5" 
    + "1fe0873666a62459581669b510ae1e84bef6bcb1aff7957237279d8b7e0e25b71ad39df3684"
    + "5b7db60382c8eb73f289823578d33c09e48d0d2f90ed4541e1438008142ef714bfe604c41a4" 
    + "957a4f6e6ab36b9715ec57625904c6")
 */

System.Object
   System.Attribute
     System.Security.Permissions.SecurityAttribute
       System.Security.Permissions.CodeAccessSecurityAttribute
        System.Security.Permissions.StrongNameIdentityPermissionAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: