Click here to Skip to main content
14,093,048 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


31 bookmarked
Posted 15 Nov 2009
Licenced CPOL

Copy DLL from GAC

, 15 Nov 2009
Rate this:
Please Sign up or sign in to vote.
This article demonstrates how to copy DLL from Global Assembly Cache.


The idea behind writing this article is to share solution to one problem that I faced recently for one my project. The problem was how we can copy an assembly (.DLL) file from Global Assembly Cache (GAC). Well, if it simply copy and paste then I am wasting my and your valuable time over here. There is no point have an article such as this. When you read the article heading, it looks pretty simple but it is not. Let’s first start with the basics. 


Assembly: According to MSDN “Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. 
There are two types of assembly 
  • Private: The assembly which is used only by a single application is called as private assembly.It does not require strong name and versioning.
  • Shared: Assembly which can be used across multiple applications is called shared assembly. 
Click here to find more details about assembly.  

GAC (Global assembly cache):  GAC is a place where .NET assemblies are stored, specifically used to be shared by multiple applications on that computer.  

GACUtil is a command line tool which allows you to place, to remove assembly from GAC.  

To install an assembly called VirendraAssembly in the GAC, you can use the command 
gacutil /i VirendraAssebmly.dll   

To uninstall an assembly called VirendraAssembly in the GAC, you can use the command,  

gacutil /u VirendraAssebmly.dll  

I will not go into the details of gacutil you can find from this link<o:p>

But have you ever tried to copy DLL from GAC (Global assembly cache)? Well, first time when someone asked me, I said go to GAC (c:\Windows\Assembly) folder, Select the assembly you want to copy, then right click on it and select copy option and paste it at your desired location. Well, I tried the same way but unfortunately there is no option available to copy when you make a right click on any assembly. Only available options are uninstall and properties option. 

See the below screen shot.  


One more thing that is noticeable is, go to DOS prompt and fire DIR command to see the listing of C:\Windows\Assembly folder and you will be surprised to see the listing. See below screen shot.   


Where C:\Windows\Assembly folder looks like this.See Screenshot below:  


Surprised!! Well, what you see on the DOS Prompt is the internal structure of GAC folder then why windows is not showing such structure of the GAC. Well, this is because off SHFusion.dll (Assembly cache Viewer). On the Dos Prompt fire Dir /AH command. It shows desktop.ini. SHFusion.dll uses this desktop.ini file to show abstract view of GAC. 

Various Techniques to show internal structure of GAC

There are 4 ways to show the same structure for GAC in windows as we will in DOS.

Rename the Desktop.ini file


As I mentioned previously, SHFusion.dll make use of desktop.ini to determine how to display the content of the GAC folder. From DOS prompt, fire these commands to rename the desktop.ini file. 

attrib desktop.ini -h -r -s
rename desktop.ini desktop.ini.bak 

Now, go to C:\Windows\Assembly folder to see its content. Screen will look something like below screenshot.


You can also see the particular folder content. Select GAC and you will see something like this. 

If you want to see both the view together run this series of commands on DOS Prompt. 

Assuming you are on c:\ drive. 

cd Windows\Assembly 
attrib -r -h -s desktop.ini 
mkdir OriginalView  
move desktop.ini OriginalView 
attrib +s OriginalView  
attrib +r +h +s OriginalView/desktop.ini

Now, go to assembly folder. You will internal structure of GAC and plus one more folder named OriginalView. When you go in this folder, you will see original view of GAC. 

By modifying the registry

The following steps will modify the registry. If you make any incorrect entry in registry, that can cause some serious problems. Sometimes you may need to install operating system again. Use registry editor at your own risk. I prefer, before you follow these steps, take a backup of registry.We need to add a key in registry that will disable the abstract view of the GAC. 

To open registry editor, Go to Run and type regedit. Locate following registry, in the registry editor "HKEY_Local_Machine\Software\Microsoft\Fusion\" 


Right click on Fusion Folder and select New ->DWord Value.


Add a new Dword named “DisableCacheViewer” and set its value 1.

Now go to C:\Windows\Assembly folder and you will see folders in GAC.

By Uninstalling SHFusion.dll 

Go to Visual Studio Command Prompt and fire this command to uninstall the SHFusion.dll 
regsvr32 -u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll 


Following message will appear.


Now go to C:\Windows\Assembly folder and you will see folders in GAC.
To get back to the previous state of view register the SHfusion.dll using the following command, fire this command on Visual Studio Command prompt.

regsvr32 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll 

And you will see following message on the screen.


Now go to Assembly folder again and it will show the abstract view of GAC.

Using SUBST Command

Go to Windows DOS Prompt and type following command and press enter. 
SUBST L: “C:\Windows\Assembly” 

This command will create a virtual drive “L” and this drive will have the internal view of GAC, where C:\Windows\Assembly will have the abstract view of GAC. Kindly ensure that the drive name that you type in SUBST command, it must not exist in your system. Go to My Computer and you will see the Drive named “L:”.

Now to delete this drive, run this command on command prompt.
This will delete the L: drive. 

Folder Structure

By all above these four techniques, you can see the internal structure of GAC. Via Internal structure you can copy the DLL and paste it at desired location.
Now, let’s see what every folder contains in GAC. Mainly there are 5 Folders.
  1. GAC : This folder contains non-native images of DLL used in .NET Framework 1.x. 
  2. GAC_32 : A 32-bit system will only have the GAC_32 directory.  A 64-bit system will have both the directory GAC_32 and GAC_64. These directories contain assemblies that are specific to 32-64 bit mode. 
  3. GAC_MSIL: The GAC_MSIL cache contains assemblies that can be run in either 32-bit or 64-bit mode. They don’t have any dependency.


  4. NativeImage Framework Version :  Native image generated for Framework version. If you have .NET Framework 1.0 and 2.0 both, then there will be two directories.


  5. Temporary and Tmp : Temporary Directories.
The folder GAC, GAC_32, GAC_64 and GAC_MSIL contains non-native images of the DLLs. They all contain the MSIL that will be complied into native images and placed in NativeImage_Framework Version folder. 



During this article, I have showed you various techniques to show internal structure of GAC and one can easily copy the DLL from the GAC folder and can paste it at desired location. I hope that readers will learn something new.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Talking Dotnet
Technical Lead
India India
I am an experienced Software Developer with 11+ years of hands-on experience working with Microsoft.NET technology (ASP.NET, ASP.NET Core, C#, SQL Server, Angular).

Visit Talking Dotnet
For ASP.NET Core, read ASP.NET Core Articles

You may also be interested in...

Comments and Discussions

SuggestionHeading Makes it confusing Pin
stixoffire21-Apr-15 10:45
memberstixoffire21-Apr-15 10:45 
GeneralMy vote of 5 Pin
rama charan11-Oct-11 20:25
memberrama charan11-Oct-11 20:25 
GeneralRe: My vote of 5 Pin
Member 411560410-Aug-13 17:17
memberMember 411560410-Aug-13 17:17 
GeneralSo thorough, very helpfull, just perfect. Pin
Dimitrios Kalemis25-Nov-09 12:54
memberDimitrios Kalemis25-Nov-09 12:54 
GeneralRe: So thorough, very helpfull, just perfect. Pin
Talking Dotnet25-Nov-09 17:00
memberTalking Dotnet25-Nov-09 17:00 
GeneralThanks Pin
Muralidharan Deenathayalan16-Nov-09 3:12
memberMuralidharan Deenathayalan16-Nov-09 3:12 
GeneralRe: Thanks Pin
Talking Dotnet16-Nov-09 17:00
memberTalking Dotnet16-Nov-09 17:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190518.1 | Last Updated 16 Nov 2009
Article Copyright 2009 by Talking Dotnet
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid