How to extract an assembly from the GAC?
Solution 1:
I 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
Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll
- 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.
Open “%windir%\assembly\GAC_MSIL”.
Browse to your DLL folder into the deep to find your DLL.
Copy the DLL somewhere on your hard disk and refer it from there in your project
Run "regsvr32 %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.
Solution 2:
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
Summary from Article:
- Map a Network Drive (Explorer -> Tools)
- Map to \servername\folder (
\\YourServer\C$\Windows\Assembly
)
- Map to \servername\folder (
- No need for sharing if you are the Administrator
- Browse to the drive and extract your assembly
Solution 3:
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!
Solution 4:
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.
Solution 5:
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.