Pages

Tuesday, February 8, 2011

Use of sn Strong Names

GAC is Global access cache sometimes I also heard it as Global Assembly cache.
GAC is used particularly when a dll or assembly is needed by many programs and that requires some Administrative security rights to work.In this case that dll is placed under "C:/windows/Assamblies/GAC" depending on the type of GAC folder When I dir my "C:/windows/assembley" folder I get following GAC's
  1. GAC
  2. GAC_32
  3. GAC_MSIL
Since GAC stores assemblies common to all problem of DLL HELL can occur which means two different apps with requirement of same dll with different versions may not be able to work simultaneously. Since their requirement is of only1 concerned dll and only 1 version of a dll can be present at a time in GAC.

This problem is solved using sn or Strong Naming where a hash value of dll is taken and is decoded using a private key and a public key is added to the resultant information or to its name.
Thus multiple versions of same dll can be used with different public keys.

This can be seen here in the below figure

Here if you see in the end there is a dir in the end with name 2.0.0.0__b77a5c561934e089 the first part here implies the version and second part implies the public key.
We can also create Strong Names of our own dll's a tool called gc.exe comes with Visual studio for that purpose I will cover the use of that tool in my next post.

No comments:

Post a Comment