Well, today I am going to write a simple but useful utility program that can be used to extract the .NET assemblies from the Global Assembly Cache.
Couple of days ago, I was working with the SharePoint object model and I found that I need to extract some assemblies that are installed in the GAC of my machine. And there was no ready-made tool to do that task. That's why I thought of writing one and posting it here so that next time, it would be easier to do this for me as well as for other developers.
Using the code
I guess most of the readers know the structure of the GAC. But I am explaining it again briefly here. After installation, .NET assemblies remain in the $(windir)\assembly\GAC directory which can be found in the Windows directory (this is the usual scenario). And inside this directory, an assembly is stored under a directory which has a name similar to that of the assembly. Inside this directory there is another directory which is named XXXXX__YYYYY and underneath this directory the actual assembly is stored. Here XXXXX is the version number of the assembly and YYYYY is the public key token. This is because you know that .NET eliminates the "
DLLHELL" with its elegant side by side execution. So another assembly that has the same name but a different version can be stored in the GAC without any ambiguity.
Well, inside the code I am just exploring the $(windir)\assembly\ directory programmatically. You cannot explore this directory using Windows explorer. The only way to see the real content of this directory is by using the command shell.
There is nothing more to say here. The code is pretty simple. It simply explores that directory and provides some functionality to extract/install one or more assemblies from/to the Global Assembly Cache.
I hope you will enjoy this!