In .NET assemblies can be broadly classified into 2 types
- Weak Named Assemblies
- Strong Named Assemblies
An assembly name consists of 4 Parts
- Simple textual name.
- Version number.
- Culture information (otherwise the assembly is language neutral)
- Public key token
We use AssemblyVersion attribute to specify the Assembly
version. The default is 1.0.0.0. The version number of an assembly consists of
the following 4 parts:
- Major Version
- Minor Version
- Build Number
- Revision Number
Strong naming an assembly AssemblyCulture attribute is used
for specifying the culture. By default, an assembly is language neutral. If you
specify any string other than an empty string for the culture parameter, the
assembly becomes a satellite assembly. In fact, compilers use this attribute to
distinguish between main assembly (language neutral) and a satellite assembly.
To generate the key pair, use strong naming tool
sn.exe-kc:\KeyPairFile.sk
To strong name an assembly
[assembly: AssemblyKeyFile("KeyPairFile.snk")]
A strongly named assembly should have all of the following
- The textual assembly name.
- The assembly Version number.
- The assembly should have been signed with private / publickey pair.
If the assembly is not signed with private/public key pair,
the assembly is weak named and not guaranteed to be unique, and may cause DLL
hell.
Strong named assemblies are guaranteed to be unique and
solves DLL hell. You cannot install an assembly into GAC unless, the assembly
is strongly named.
Sign up here with your email