C# and .NET interview questions and answers around global assembly cache (GAC)
One of the most asked questions in .NET interviews are around assembly and GAC. Most of the times .NET developers get confused with these questions. Below are some of the question which keeps coming from GAC perspective.
Interviewer normally starts with what is GAC?
GAC is a central repository folder where you can share your DLL among different applications running in the same computer. So for example you have accounting and invoicing application running in the same computer and both these application need some common utility like the logging DLL then you need to register them in GAC and share them.
If you are able to answer the top interview questions the next question can be on versioning.
If we have different versions of DLL in GAC how can the application identify them?
This is done by using binding redirect and specifying older version and new version value. So which ever version you put in the new version will be used by the application.
The other question can come from the perspective of how you can register a DLL in GAC. Interviewer expectation is that you do not just talk about GACUTIL but you need talk more realistic.
What are the various ways by which you can register a DLL in GAC?
We can use the GACUTIL tool to register the DLL in GAC.
But when we talk about application they have 100 of DLL’s so how feasible is GACUTIL tool?
We need to create installation package which will register the DLL in GAC.
If we do not have strong name can assembly be registered in GAC?
This is again a catchy question which is testing do you know the pre-requisites to register DLL in GAC. No, you cannot register DLL in GAC without strong names.
How do we create strong named DLL?
By using SN.EXE or by going to the project properties and making the assembly string named.
So next time you face a question in GAC in C# and .NET interviews understand the above twist and twirls. Happy job hunting.
C# and .NET interview questions and answers
write a comment