Edit

Share via


ApplicationId.PublicKeyToken Property

Definition

Gets the public key token for the application.

public:
 property cli::array <System::Byte> ^ PublicKeyToken { cli::array <System::Byte> ^ get(); };
public byte[] PublicKeyToken { get; }
member this.PublicKeyToken : byte[]
Public ReadOnly Property PublicKeyToken As Byte()

Property Value

Byte[]

A byte array containing the public key token for the application.

Examples

The following code example displays the PublicKeyToken property by obtaining the ApplicationId from an ApplicationSecurityInfo instance created using the ActivationContext for the currently executing manifest-based application. This code example is part of a larger example provided for the ApplicationId class.

// To display the value of the public key, enumerate the Byte array for the property.
Console.Write("ApplicationId.PublicKeyToken property = ");
byte[] pk = asi.ApplicationId.PublicKeyToken;
for (int i = 0; i < pk.GetLength(0); i++)
    Console.Write("{0:x}", pk[i]);
// To display the value of the public key, enumerate the Byte array for the property.
printf "ApplicationId.PublicKeyToken property = "
let pk = asi.ApplicationId.PublicKeyToken
for i = 0 to pk.GetLength 0 - 1 do
    printf $"{pk[i]:x}"
' To display the value of the public key, enumerate the Byte array for the property.
Console.Write("ApplicationId.PublicKeyToken property = ")
Dim pk As Byte() = asi.ApplicationId.PublicKeyToken
Dim i As Integer
For i = 0 To (pk.GetLength(0))
    Console.Write("{0:x}", pk(i))
Next i

Remarks

The public key token is represented by the last 8 bytes of the SHA-1 hash of the public key under which the application is signed.

For more information, see AssemblyName.GetPublicKeyToken.

Applies to