Wednesday, 30 May, 2007

Questions related with assemblies

Q .How should an assembly be uninstalled
A.Uninstalling an assembly should be done with care.
The following command removes the assembly hello from the global assembly cache(GAC) as long as no reference counts exist for the assembly.
gacutil /u hello

Note : If there is only one version of hello assembly the above command is fine and you are in safer side. Incase if there are more than one version of the assembly or different assembly with same name exists then the above command might remove more than one assembly from the assembly cache because the assembly name is not fully specified. For example, if both version 1.0.0.0 and 3.2.2.1 of hello are installed in the cache, the command gacutil /u hello removes both of the assemblies.

Then how to remove the assembly safely: Use the following example to avoid removing more than one assembly. This command removes only the hello assembly that matches the fully specified version number, culture, and public key.
gacutil /u hello, Version=1.0.0.1, Culture="de", PublicKeyToken=45e343aae32233ca

Q . How do I see the physical file structure of GAC in explorer and how can one debug assemblies in GAC?

A. It is possible to see physical file structure of GAC folder.

As such Winnt\assembly\gac cannot be browsed using windows explorer.
To view the physical file structure add a binary value named 'DisableCacheViewer' to the registry key HKLM\Software\Microsoft\Fusion and set it to a non-zero value.

An alternative to this is by opening visual studio command prompt and navigating to
cd c:\%windir%\assembly\gac and listdown the directories by using the dir commandthere will be individual directory for every assembly installed in GAC.If you will further drilldown
to the hierarchy of assembly you will see a folder starting with version number and ending with public key of the assembly
something like : 1.0.5000.0__b03f5f7f11d50a3a
In thats particular folder you will find the copy of the assembly , if you want to debug an assembly which is installed in gac(Shared Assembly) then you need to copy the pdb file here.