Follow

Getting Files Out of 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 are many ways to get the DLL file from GAC.

Method-1
(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\ \shfusion.dll ” to re-register the shfusion.dll file and regain the original distinct view of the GAC.

Method-2
(1) Open command prompt and type: cd windows\assembly\GAC_MSIL.
(2) Type the name of the DLL which has to be retrieved from the GAC, for example to copy the System.core dll type “cd system.core” in the CMD window.
(3) Now we’ve to go to the appropriate .NET framework folder. If you’re not sure of the folder structure simply type this in the CMD window “dir *.*”
(4) Once the framework directory is located type “cd ”.
For example, use the below command to move to .NET framework version 3.5 folder
cd 3.5*
(5) Now type “copy system.core.dll D:\System.core.dll”, which will copy the DLL to the D drive. Replace “D:\” with the desired drive letter.

Are you interested? follow us and get notified of new posts

Leave A Reply

13 − nine =