Retrieving GAC Assemblies and Information

less than 1 minute read

Retrieving GAC assemblies and their information.  This was a question posed by one of my colleagues while he was developing a product. Now the answer to this is little tweaky.

Follow these steps to get information such as:-

  1. Assembly Name
  2. Version
  3. PublicKeyToken

I prefer not to use Reflection for this purpose and solving by a simple File Iteration method.

Iterate through directories in GAC


Now this GAC folder within Assembly is not visible in Windows Explorer, but you can see this on your Command Prompt.

Iterate through Files in each directory in GAC

Files = System.IO.Directory.GetFiles(currentDirectory, "*.dll");

This will give you the Assembly Name.

Iterate through the directories in this folder

For example, C:WindowsassemblyGACADODB has only one folder: 7.0.3300.0__b03f5f7f11d50a3a

Split this by '_' to get two parts. Part-I represents the version of the assembly and Part-II represents PublicKeyToken

This is faster than using reflection and is easy to develop as well.

Happy development!