Friday, March 12, 2010

Getting an Assembly From the GAC

Windows Explorer lets you browse the Global Assembly Cache (GAC) and drop strongly-named assemblies in if you’ve the proper permissions. What you can’t do is pull things out of the GAC using Explorer. Explorer hides some abstractions of the GAC from you, preventing you from pulling assemblies out.

I had the need to validate that an assembly in the GAC was indeed the version I expected; however, once a file’s in the GAC you can’t just drag it out using Explorer. (I couldn’t rely on the Version number shown in Explorer – it’s a DLL related to some SharePoint work and the pain of dealing with versioned assemblies in SharePoint is a rant I’ll save you from. Today.)

You can get around this with a quick bit of command-line fu, though. Actually, it’s just copy, so it’s not even fu.

Using an admin account, open a command prompt and change to the %SYSTEMROOT%\assembly folder. There are a number of folders under here:

C:\Windows\assembly>dir /b

Use dir /s to find the assembly you’re looking for. (Line breaks inserted)

C:\Windows\assembly>dir TelligentEvolution.Wss.Global.dll /s /b

Now you’ve got the full path to the assembly. Use copy to get it where you want it.

C:\Windows\assembly>copy GAC_MSIL\TelligentEvolution.Wss.Global
        1 file(s) copied.

Poof. Now I can get at the file with Reflector for a bit of inspection.


Jason Follas said...

subst g: c:\windows\assembly

Then you can access the GAC as a drive (i.e., not as a special folder)

HashName said...

Easiest method..
Type C:\WINDOWS\assembly\gac_msil in Start > Run. That's it..

Subscribe (RSS)

The Leadership Journey