![]() |
Platforms, Frameworks & Libraries »
.NET Framework »
General
Beginner
License: The Code Project Open License (CPOL)
Copy DLL from GACBy Virendra DugarThis article demonstrates how to copy DLL from Global Assembly Cache. |
.NET, Dev
|
||||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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.
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.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.
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.
There are 4 ways to show the same structure for GAC in windows as we will in DOS.
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.
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.
regsvr32 -u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll
Following message will appear.
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.
SUBST L: “C:\Windows\Assembly”
SUBST L: /DThis will delete the L: drive.
| You must Sign In to use this message board. | |||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 16 Nov 2009 Editor: |
Copyright 2009 by Virendra Dugar Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |