This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Creating Assemblies with Shared Names
Tools assign shared names to assemblies using the crypto helper API's and the assembly metadata API's. The basic steps are as follows:
- A developer indicates that he'd like to give the new assembly a shared name. Presumably, this is either done through a dialog in the IDE or as a command line switch to the compiler/linker.
- The tool should allow the developer to designate the key pair to use for the shared name. This may be:
- an existing key pair stored in a file using the portable key blob format
- the default key pair installed on the machine, the tool should know the container name of this key
- a new key generated by a call the the Crypto helper API StrongNameKeyGen
- The tool must reserve space in the PE containing the manifest for the shared name signature and set the StrongNameSignature field in the COR Header to point to this space. The size required for the signature can be determined using StrongNameSignatureGeneration.
- When generating the manifest, the tool passes in the public key associated with the shared name as a parameter to IMetadataAssemblyEmit::DefineAssembly (the parameter is called Originator).
- After the assembly has been built, the tool needs to generate the shared name and store it in the PE file containing the manifest. This is done by calling StrongNameSignatureGeneration. This function will insert the shared name signature blob into the StrongNameHash section reserved in the PE by default.