Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




.NET interview questions: - What is GAC (Global Assembly Cache)?

Following is the one of the basic .NET interview questions asked during interview. Do revise the same on GAC.

GAC (Global Assembly Cache) is where all shared .NET assembly resides. GAC is used in the following situations:-
  • If the application has to be shared among several application which is in the same computer.

  • If the assembly has some special security, requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.

Adding and removing of an assembly from GAC

You can use the ‘GacUtil’ tool which comes with visual studio. So to register an assembly in to GAC go to “Visual Studio Command Prompt” and type “gacutil –i (assembly name)”, where (assembly name) is the DLL name of the project.

One you have installed the assembly the DLL can be seen in ‘c:\windows\assembly\’ folder.

When we have many DLL’s to be deployed we need to create setup and deployment package using windows installer. So the common way of deploying GAC DLL in production is by using windows installer.

Choosing from two versions of the same assembly in GAC  

When we have two version of the same assembly in GAC we need to use binding redirect tag and specify the version we want to use in the new version property as shown in the below “app.config” file.

<configuration>

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>

<assemblyIdentity name="ComputerName" publicKeyToken="cfc68d722cd6a164" />

<publisherPolicy apply="yes" />

<bindingRedirect oldVersion="1.1.0.0" newVersion="1.0.0.0" />

</dependentAssembly>

</assemblyBinding>

</runtime>

</configuration>

Below is a .NET video created by www.questpond.com which discusses one more important .NET interview question which talks about IL Code, JIT, CLR, CTS and CAS.

Helpful Website Url
http://www.questpond.com/
Share this article   |    Print    |    Article read by 11155 times
Author:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers
Related Articles: No related article
Related Interview Questions: