private void ComputePublicKeyToken() { var pubKey = (_certificate.PublicKey.Key as RSACryptoServiceProvider).ExportCspBlob(false); var strongNameKey = new byte[pubKey.Length + 12]; // the strong name key requires a header in front of the public key: // unsigned int SigAlgId; // unsigned int HashAlgId; // ULONG cbPublicKey; pubKey.CopyTo(strongNameKey, 12); // Set the AlgId in the header (CALG_RSA_SIGN) strongNameKey[0] = 0; strongNameKey[1] = 0x24; strongNameKey[2] = 0; strongNameKey[3] = 0; // Set the AlgId in the key blob (CALG_RSA_SIGN) // I've noticed this comes from the RSACryptoServiceProvider as CALG_RSA_KEYX // but for strong naming we need it to be marked CALG_RSA_SIGN strongNameKey[16] = 0; strongNameKey[17] = 0x24; strongNameKey[18] = 0; strongNameKey[19] = 0; // set the hash id (SHA_1-Hash -- 0x8004) // Still not sure *where* this value comes from. strongNameKey[4] = 0x04; strongNameKey[5] = 0x80; strongNameKey[6] = 0; strongNameKey[7] = 0; strongNameKey[8] = (byte)(pubKey.Length); strongNameKey[9] = (byte)(pubKey.Length >> 8); strongNameKey[10] = (byte)(pubKey.Length >> 16); strongNameKey[11] = (byte)(pubKey.Length >> 24); StrongNameKey = strongNameKey; PublicKeyToken = UnitHelper.ComputePublicKeyToken(StrongNameKey).ToHexString(); }