Tuesday, June 30, 2009

Strong Assembly and Weak Assembly

Both compailer are created by Compailer and AL.exe(Assembly linker,which helps to create the assembly in your project also helps to add new modules.).But the difference is only the Private and public keys.

Weak Assembly : can deploy in your application directory.Not globally(ie in GAC)
Strong Assembly: Can deploy both in application directory and globally.

if you want to create your application as strong ,you should give sigining from your project properties.it will create a public key after that only you can deploy in GAC.

sigining :sn.exe(Strong name tool) is responsible for creating the public key ,which is a part of .Net SDK(.NET Software Development Kit) .More Details

Note : the combination of file name,assembly version ,culture and the public key gives the strong name,which is guaranteed to be unique.

you can check the public key value by take command prompt of visual studio
and map your dll path(C:\Documents and Settings\anish\My Documents\Visual Studio 2008\Projects\AnishClassDll\AnishClassDll\bin\Debug) then type sn -T demo.dll.

this public key is you are given in the web config file to map this to the particular location.

Note :when you create a strong name it create a unique key like this
070200000024000052534132000400000100010031f38d3b2e55454ed52c5d2469 11011be59543

it is difficult to read the developer so modified to a human readable form like

Why the strong name is needed ?

This is the way that the compailer finds which assembly it wants to load.only one public key with same name is accepted in GAC.