Partilhar via


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

  • Anonymous
    January 13, 2009
    There is also Option 4: Use good old Total Commander

  • Anonymous
    January 13, 2009
    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.

  • Anonymous
    January 14, 2009
    Great tips!

  • Anonymous
    January 14, 2009
    The comment has been removed

  • Anonymous
    January 16, 2009
    Web Web Design Trends For 2009 Why learning CSS is important in a (web) development world - Fizzler:

  • Anonymous
    January 16, 2009
    WebWebDesignTrendsFor2009WhylearningCSSisimportantina(web)developmentworld-...

  • Anonymous
    February 02, 2009
    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

  • Anonymous
    June 01, 2009
    This might help http://snahta.blogspot.com/2009/01/file-path-for-gac-assemblies.html

  • Anonymous
    July 27, 2010
    Many thanks Benjy ! I used GACView - works fine Thanks

  • Anonymous
    April 06, 2011
    Copy c:windowsassembly to c:tmpassembly then you can browse it.

  • Anonymous
    February 02, 2012
    Excellent Share It worked for me

  • Anonymous
    February 14, 2012
    great post. I found one more intersting blog.kumarvineet.com/.../Copy-dll-from-GAC.aspx

  • Anonymous
    March 14, 2012
    The comment has been removed

  • Anonymous
    March 18, 2013
    How to remove the Drive G again from option #3? Is it possible?

  • Anonymous
    May 01, 2013
    to remove G drive use SUBST G: /D

  • Anonymous
    October 23, 2013
    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.
  • Anonymous
    December 21, 2013
    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)

  • Anonymous
    March 10, 2014
    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

  • Anonymous
    January 30, 2015
    you have to open it from run prompt Start->Run->C:WindowsAssemblyGAC_MSIL

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

  • Anonymous
    May 14, 2015
    ....well just C:WindowsAssembly seems to be empty

  • Anonymous
    August 18, 2015
    Thanks for the SUBST command.  Worked great.

  • Anonymous
    September 17, 2015
    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.