Use StrongNameIdentityPermission to achieve versioning and naming protection by confirming that the calling code is in a particular strong-named code assembly.

A strong name identity is based on a cryptographic public key called a blob optionally combined with the name and version of a specific assembly. The key defines a unique namespace and provides strong verification that the name is genuine, because the definition of the name must be in an assembly signed by the corresponding private key.

Note that the validity of the strong name key is not dependent on a trust relationship or any certificate necessarily being issued for the key.

Note

Full demands for StrongNameIdentityPermission succeed only if all the assemblies in the stack have the correct evidence to satisfy the demand. Link demands using StrongNameIdentityPermissionAttribute succeed if only the immediate caller has the correct evidence.

The StrongNameIdentityPermission class is used to define strong-name requirements for access to the public members of a type. The StrongNameIdentityPermissionAttribute attribute can be used to define strong-name requirements at the assembly level. In .NET Framework version 2.0 you can also use InternalsVisibleToAttribute to specify that all nonpublic types in that assembly are visible to another assembly. For more information see Friend Assemblies (C# Programming Guide).

The following code example demonstrates the use of the StrongNameIdentityPermission class. The example is in the form of a class library, which applies both the StrongNameIdentityPermissionAttribute attribute and the StrongNameIdentityPermission to demand that the caller be signed with a specific strong name.

The following code example demonstrates the behavior of the StrongNameIdentityPermission methods. The purpose of this sample is to show the results of the methods, not to show how the methods are used.