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
GAC
GAC_32
GAC_64
GAC_MSIL
NativeImages_v2.0.50727_32
NativeImages_v2.0.50727_64
temp
tmp

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

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

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
   \4.1.31029.3047__454c7a96e9526647\TelligentEvolution.Wss.Global.dll 
   d:\temp
        1 file(s) copied.

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

2 comments:

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