How to Copy an Assembly From the GAC to the File System


Sometimes you need a local copy of an assembly from the GAC and here is a quick tip on how to do it.  The GAC can be found in the c:\windows\assembly directory, but if you try to browse it, the following custom shell extension appears:


image


This view does not provide the ability to copy assemblies, but it does provide some very useful information such as the strong name details.  Here are some options to get around that feature to copy an assembly from the GAC.


Option 1: Disable the Shell Extension in the Registry


One possibility, but not the best one, is to disable the shell extension.  I don’t like this approach because it involves editing the registry and I like the information provided by the shell extension.  Here’s how to disable the extension if you want to.  Open the registry editor and add/set the HKLM\Software\Microsoft\Fusion\DisableCacheViewer DWORD value:


image


Set the value to 1:


image


Once you make that change, you can browse the directory:


image


 


Option 2: Go Command-O


Another option is to copy assemblies from the GAC from the command line.  This approach works well if you prefer working from the command line, but if you like to right-click with a mouse, this might not be the choice for you.


I highly recommend PowerShell, but you can use Windows Command Prompt.  Find your way to the c:\windows\assembly directory and copy the file you need:


image


Option 3: Use the SUBST Command


The SUBST command allows you to create a shortcut to a path on your file system and assigns that shortcut a drive letter.  I really like this approach because you have the option of using Windows Explorer without having to disable the shell.


Suppose you want to create a G Drive (G for GAC), use the following command: SUBST G: C:\WINDOWS\ASSEMBLY


image


Then in Windows Explorer you are free to double-click and right-click to your heart’s content and still use the shell extension. 


image

Comments (23)

  1. Przemyslaw Wlodarczak says:

    There is also Option 4: Use good old Total Commander

  2. Ross Beehler says:

    Another way is to type a path beyond ‘C:windowsassembly’ in the Run window.  If you’re running .NET 2.0 or greater, try ‘C:windowsassemblyGAC_MSIL’ and it will open up an explorer window to that folder.  Do note that this method does not work from an open explorer window, but only the Run window.

  3. johnwpowell says:

    Great tips!

  4. Great tips.

    Option #X :

    In the c:WindowsAssembly directory, you’ll find a hidden file called desktop.ini – remove or rename this.

    From command line you can see it by going into that directory and typing "dir /a".

    Then do : "attrib -h desktop.ini" and "ren desktop.ini desktop.tmp".

  5. gOODiDEA.NET says:

    Web Web Design Trends For 2009 Why learning CSS is important in a (web) development world – Fizzler:

  6. gOODiDEA says:

    WebWebDesignTrendsFor2009WhylearningCSSisimportantina(web)developmentworld-…

  7. Benjy says:

    I use a free tool called GACView by NirSoft, which allows you to copy out assemblies to any folder you want. Very useful tool. It also shows more columns than the default shell extension and its easier to search and filter.

    HTH,

    Benjy

  8. Mike says:

    Many thanks Benjy !

    I used GACView – works fine

    Thanks

  9. Simon says:

    Copy c:windowsassembly to c:tmpassembly then you can browse it.

  10. sameer dubey says:

    Excellent Share

    It worked for me

  11. sunny says:

    great post. I found one more intersting

    blog.kumarvineet.com/…/Copy-dll-from-GAC.aspx

  12. Dana says:

    And if you're going the PowerShell command line route, you can always setup a PowerShell drive for easy access:

    PS:>New-PSDrive -Name GAC -PSProvider FileSystem -Root C:Windowsassembly

    PS:>dir gac:

  13. Thiru says:

    How to remove the Drive G again from option #3? Is it possible?

  14. Vandana Thakur says:

    to remove G drive use SUBST G: /D

  15. Sanni says:

    Very easy way to copy the dll.

    1. Go to start -> run

    2. Type following C:windowsassemblyGAC_32 and press enter

      It will open windows explorer that let you copy the dll you want.

    That's it.

  16. Jaff says:

    or you might use a filemanager laike TotalCommander to gain acces to hidden folders etc (check options of TC to show hidden files and folders)

  17. Vivek says:

    Hey,

    Another simple solution I came across when working on this is.. To map the location of the assembly location as a network drive on your computer! Voilaa! you'll have all the files visible

    Thanks

    Vivek

  18. Sriman says:

    you have to open it from run prompt

    Start->Run->C:WindowsAssemblyGAC_MSIL

  19. Anonymous says:

    I tried the G drive option, then removed it as suggested above, now I can see anything in my C drive?!!

  20. Anonymous says:

    ….well just C:WindowsAssembly seems to be empty

  21. John C says:

    Thanks for the SUBST command.  Worked great.

  22. Barbiduc says:

    A plain easy solution without having to find ways to get to GAC_MSIL folder is to simply Add Reference -> Browse -> C:WindowsAssemblyGAC_MSILMicrosoft.ReportViewer.WebForms and you can pick up the dll from there. Make sure you set Copy Local to true and you're done.