Strong named assemblies in VB.NET y C++/CLI, C#

What's the use of having "strong named assemblies"?

  1. A strong name is unique. Therefore, if an assembly has a unique name, all types defined in it have a unique name as well.
  2. Assemblies without strong naming can only be found by the CLR if they are placed in the same directory as the referencing assembly or in special directories (like System32 or any other referenced by the PATH environment variable). A strong named assembly offers more possibilities (more on that in future posts).
  3. When an assembly is sought during runtime, its Name, Culture and Public Key Token are compared to see if there is a successful match. The assembly's version number is only taken into account in the comparison when the assembly has a strong name. This eases DLL Hell and encourages using version numbers for dlls.
  4. So that FxCop doesn't complain :P

At least in Visual Studio 2008 is quite easy to have a VB.NET or C# class library output a strong named dll. What we need is a file encrypted with a Public Key Token, and it must be referenced by the project.

A word of warning: Pure Managed strong named assemblies (C#, VB.NET, etc) sólo can only reference Managed or Mixed strong named assemblies (C#, VB.NET, C++/CLI, etc). It's alright to reference an unmanaged assembly with no strong name, though.

Instructions to give a strong name to a C# or VB.NET assembly (MSDN)

The same for C++/CLI projects (it's a bit less direct)

Comments

Popular posts from this blog

VB.NET: Raise base class events from a derived class

Apache Kafka - I - High level architecture and concepts

Upgrading Lodash from 3.x to 4.x