Retrieving GAC Assemblies and Information
Follow these steps to get information such as:-
- Assembly Name
- Version
- PublicKeyToken
I prefer not to use Reflection for this purpose and solving by a simple File Iteration method.
Iterate through directories in GAC
System.IO.Directory.GetDirectories(@”C:WindowsAssemblyGAC”);
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!
References: Retrieving GAC Assemblies and Information from our NCG partner Punit Ganshani at the Punit Ganshani blog.