/// <summary> /// Generates a strong name signature for the specified assembly, according to the specified flags. /// </summary> /// <param name="filePath">The path to the file that contains the manifest of the assembly for which the /// strong name signature will be generated.</param> /// <param name="keyPair">A pointer to the public/private key pair.</param> /// <param name="flags">Flags</param> public static byte[] GenerateSignatureFromKeyContainer(string filePath, string keyContainerName, StrongNameGenerationFlags flags) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullOrEmptyException("filePath"); } if (string.IsNullOrEmpty(keyContainerName)) { throw new ArgumentNullOrEmptyException("keyContainerName"); } IntPtr signatureBlobPtr = IntPtr.Zero; try { int signatureBlobSize = 0; if (!StrongNameNative.StrongNameSignatureGenerationEx( filePath, keyContainerName, null, 0, out signatureBlobPtr, out signatureBlobSize, flags)) { Marshal.ThrowExceptionForHR(StrongNameNative.StrongNameErrorInfo()); } byte[] signatureBlob = new byte[signatureBlobSize]; Marshal.Copy(signatureBlobPtr, signatureBlob, 0, signatureBlobSize); return(signatureBlob); } finally { if (signatureBlobPtr != IntPtr.Zero) { StrongNameNative.StrongNameFreeBuffer(signatureBlobPtr); } } }