How can I find a .NET assembly's public key via code?
From the command line, I can use sn -Tp assemblyName to find the public key.
What's the equivalent (c# or VB) in code?
How can I find a .NET assembly's public key via code?
From the command line, I can use sn -Tp assemblyName to find the public key.
What's the equivalent (c# or VB) in code?
You want to use the AssemblyName.GetPublicKey()
method.
using System;
using System.Reflection;
class Program
{
static void Main()
{
Byte[] key = Assembly.GetExecutingAssembly().GetName().GetPublicKey();
foreach (Byte b in key)
Console.Write("{0:x}", b);
}
}