I’ve completed refactoring the Managed StrongName project, and I’ve uploaded the new sources. The changes I made were all pretty much what I laid out in the previous post. We now have two modules built, msn.exe which is a thin wrapper around MS.StrongName.dll. MS.StrongName.dll contains everything in the old StrongName.Native.dll, plus a lot of what used to be in msn.exe. However, the API exposed from MS.StrongName.dll is now a managed-friendly version of the StrongName API, rather than the P/Invokes needed to access the native version. So instead of linking to StrongName.Native.dll and calling StrongNameSignatureVerificationEx passing in some byref boolean values, and interpreting the bitwise results, you now link to MS.StrongName.dll and call Verification.VerifyAssembly(), and get an Enum back.
I think this design is much nicer, and makes it a lot easier to wrap other utilities and tools around the MSN API. And it also converts MSN.exe from sample code for the native StrongName API to sample code for the managed StrongName API … making it basically a test case.
As far as the new API goes, it’s divided into three classes:
- MS.StrongName.KeyFile – a utility class for reading and writing .snk files
- MS.StrongName.Keys – managed API for dealing with key containers, key pairs, public keys, and public key tokens.
- MS.StrongName.Signatures – managed API for dealing with strong name signatures
The native API is no longer exposed publicly, since the goal of the managed API is to provide all the functionality that the native API exposes.
So, the new project looks like this: