Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of the Global Assembly Cache (GAC)?

I have registered a DLL in the GAC. I can see the DLL in the path: c:\windows\asssembly; I suppose this means the DLL registerd correctly.

However, if i have to use the DLL in my application, I still need to click "Add Reference" and add from the above path.

So, what's the use of the GAC if I still need to add the reference again?

like image 778
happysmile Avatar asked May 10 '11 03:05

happysmile


1 Answers

From MSDN:

The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

In other words, you want to register your DLL in the GAC if multiple applications (on the same machine, of course) will share the DLL.

From your comments, however, I want to mention a few more things:

  1. You may have registered the DLL incorrectly; once your DLL is in the GAC, you should be able to add it from the same list where all the GACed DLLs are. You should not have to do it by the path.

  2. The fact that your DLL is in the GAC does not mean your code should now be able to see it by some sort of automagic; you still need a reference to it (just like you need a reference to all other .NET DLLs you depend on that are also in the GAC).

  3. Again, the advantage of the GAC is that if 3 of your applications need the DLL, you'll only have to deploy it once (you'll deploy it the GAC, instead of 3 times to each application's bin directory).

Hope this has cleared things up a bit.

like image 94
Esteban Araya Avatar answered Sep 26 '22 15:09

Esteban Araya