views:

5121

answers:

12

There is a package I have to deal with which installs assemblies straight into the GAC (e.g. somewhere deep in %windows%/assembly).

How do I exorcise the actual assembly (the DLL) from the GAC into the normal file system?

Thanks.

+3  A: 

Easy way I have found is to open the command prompt and browse through the folder you mention until you find the DLL you want - you can then user the copy command to get it out. Windows Explorer has a "helpful" special view of this folder.

David M
+13  A: 

I have used the advice from this article to get an assembly from the GAC.

Get DLL Out of The GAC

DLLs once deployed in GAC (normally located at c:\windows\assembly) can’t be viewed or used as a normal DLL file. They can’t be directly referenced from VS project. Developers usually keep a copy of the original DLL file and refer to it in the project at development (design) time, which uses the assembly from GAC during run-time of the project.

During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. Follow the following steps to copy DLL from GAC

  1. Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll
  2. shfusion.dll is an explorer extension DLL that gives a distinct look to the GAC folder. Unregistering this file will remove the assembly cache viewer and the GAC folder will be then visible as any normal folder in explorer.

  3. Open “%windir%\assembly\GAC_MSIL”.

  4. Browse to your DLL folder into the deep to find your DLL.

  5. Copy the DLL somewhere on your hard disk and refer it from there in your project

  6. Run "regsvr32 /i %windir%\Microsoft.NET\Framework\<.NET version directory> \shfusion.dll" to re-register the shfusion.dll file and regain the original distinct view of the GAC.

Andrew Hare
This works but is a little complicated. If you are not afraid of the command prompt, you can just cd into the necessary directory and copy the DLL that way.
Cheeso
+3  A: 

Yes.

Add DisableCacheViewer Registry Key

Create a new dword key under HKLM\Software\Microsoft\Fusion\ with the name DisableCacheViewer and set it’s [DWORD] value to 1.

Go back to Windows Explorer to the assembly folder and it will be the normal file system view.

mccrager
+5  A: 

The method described here is very easy:

http://andreasglaser.net/post/2008/08/05/Extract-assembly-from-Global-Assembly-Cache-(GAC)-with-network-drive-mapping.aspx

Sadjad
+1 - very easy!
TrueWill
+1  A: 

I think the easiest way is to do it through the command line like David mentions. The only trick is that the .dll isn't simply located at C:\Windows\Assembly. You have to navigate to C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_[PUBLIC KEY]. You can then do a copy using:

copy [ASSEMBLY_NAME].dll c:\ (or whatever location you want)

Hope that helps.

AdamB
A: 

This MSDN blog post describes three separate ways of extracting a DLL from the GAC. A useful summary of the methods so far given.

MagicAndi
A: 

You can just use this FREE tool to extract assemblies from the GAC..

http://www.accelerated-ideas.com/NET/Free-GAC-Extractor-Copy-Dll-Global-Assembly.aspx

Its free and copies assemblies from the GAC in seconds..

Dave jones
A: 

just navigate to C:\Windows find the [assembly] folder right click and select add to archive

wait a little

vola you have an archive file containing all the assemblies in your GAC

tsadigov
+1  A: 

You could try this link:

http://prasanjitmandal.blogspot.com/2010/05/how-to-backup-dll-from-gac-to-another.html

Hope this helps!!

Prasanjit Mandal
A: 

Open the Command Prompt and Type :

cd c:\windows\assembly\GAC_MSIL

xcopy . C:\GacDump /s /y

This should give the dump of the entire GAC

Enjoy!

Deepak_k

Deepak
Deepak, the same answer as already given by AdamB.
MagicAndi
A: 

I found the below link very useful in getting the copy of dll from gac:

http://www.tipscentre.net/Details/Copy-DLL-From-GAC-Assembly.aspx

Hope this helps.

Naveed Mazhar
A: 

One other direction--just unpack the MSI file and get the goodies that way. Saves you from the eventual uninstall . . .

Wyatt Barnett