/// <summary>
/// Generate a new key pair for strong name use
/// </summary>
/// <param name="wszKeyContainer">desired key container name</param>
/// <param name="dwFlags">flags</param>
/// <param name="ppbKeyBlob">[out] generated public / private key blob</param>
/// <param name="pcbKeyBlob">[out] size of the generated blob</param>
/// <returns>true if the key was generated, false if there was an error</returns>
[DllImport("mscoree.dll")]
public extern static bool StrongNameKeyGen([MarshalAs(UnmanagedType.LPWStr)]string wszKeyContainer, StrongNameKeyGenFlags dwFlags, Out IntPtr ppbKeyBlob, Out long pcbKeyBlob)
/// <summary>
/// Flags for StrongNameKeyGen methods
/// </summary>
public enum StrongNameKeyGenFlags : int
{
/// <summary>
/// No flags
/// </summary>
None = 0x00000000,
/// <summary>
/// Save the key in the key container
/// </summary>
LeaveKey = 0x00000001
}
This function is exported from mscorsn.dll in v1.0 and v1.1 of the .NET framework, but it will be moved to mscorwks.dll in v2.0. There is a shim in mscoree.dll which will redirect to the appropriate implementation dll, which has the same name.
Please add some!
See the sample on Shawn Farkas' blog for a complete sample of using this API: http://blogs.msdn.com/shawnfa/archive/2004/07/09/178902.aspx