Click here to Skip to main content
15,885,985 members
Articles / Operating Systems / Windows
Tip/Trick

Copying Shared Assembly from GAC

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
26 Jul 2010CPOL2 min read 14.1K   2  
This article describes how to copy an assembly from Global Assembly Cache (GAC)

Introduction


"Computer wherein the common language runtime CLR is installed has a machine-wide code cache called the Global Assembly Cache. This Global Assembly Cache stores .NET assemblies specifically designated to be shared by several applications on that computer".


Background


I faced problem where I am using a DLL in my project but by mistake got deleted, there is no source code for it to build it again and then use it, but however the assembly installed in the GAC is available. For Ex: Consider that Scheduler.dll got deleted from your project by mistake .., but is available in the GAC. As we cannot copy the DLL from GAC, and also cannot drag and drop as we do while installing. Follow the below explanation to copy the DLL from the GAC.


Explanation


The default location of the GAC is under the <%Windir% >\assembly folder. The following screen shots displays a MS DOS Command Window wherein various commands have been executed at the prompt to copy the DLL from GAC. Go to command prompt path: C:\WINDOWS\assembly


image001.png


The DIR Command displays four separate directories which are briefly described here


image06.png


Now Inside the GAC_MSIL progressively drilling through this hierarchy of folders reveals the organization of the GAC and how it implements Side-By-Side installation Below screen shot shows the Scheduler.dll


image002.png


Within each folder for a shared assembly, there is a sub folder named using the version and public key token components of the assembly
e.g. 1.0.0.0__b12b4b980378177c shown in above screen) Within this sub folder resides the actual assembly that is installed into the GAC. DisplayName, Version, Culture and PublicKeyToken are the components that uniquely identify the assembly.


image003.png


Inside 1.0.0.0__b12b4b980378177c folder you can see Scheduler.dll


image004.png


Now you can execute the COPY command to copy the dll from GAC to local system drive.


image005.png


I hope the content presented in this document is useful.


NOTE: Additionally, using MS DOS commands to alter or delete these internal folders or contents of files therein may lead to unpredictable behavior or other serious problems that may require you to reinstall the .NET Framework on the affected machine(s). Use such commands at your own risk.


License

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


Written By
Architect MNC
India India
Rajesh Sajjanar is Technical Lead working for Enterprise Dotnet applications in Bangalore, INDIA. He holds batchelor degree in Electronics and Communication Engineering from Visvesvaraya Technological University Belgaum INDIA

Comments and Discussions

 
-- There are no messages in this forum --