Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages and disadvantages of using the GAC?

Tags:

.net

gac

And on top of that, are there cases where one has to use the global assembly cache or where one cannot use it?

like image 923
FantaMango77 Avatar asked Aug 22 '08 21:08

FantaMango77


People also ask

Why would I avoid the GAC?

The best answer was that "The GAC is only useful if you register libraries which you're going to reuse." In other words, don't use it if you are not going to share libraries between different applications.

What is GAC and why it is used?

Basically GAC stores assemblies specifically to be shared by many application on computer. The Global Assembly Cache (GAC) is a folder in Windows directory to store the . NET assemblies that are specifically designated to be shared by all applications executed on a system.

What is the use of GAC in asp net?

Each computer where the Common Language Runtime is installed has a machine-wide code cache called the Global Assembly Cache. The Global Assembly Cache stores assemblies specifically designated to be shared by several applications on the computer.

Why should I store my shared assemblies in the GAC?

The Global Assembly Cache (GAC) is a central repository for storing shared assemblies. The GAC allows multiple versions of the same assembly to be installed concurrently and also prevents different assembly vendors from overwriting each other's assemblies.


2 Answers

  • Loading assemblies from GAC mean less overhead and security that your application will always load correct version of .NET library
  • You shouldn't ngen assemblies that are outside of GAC, because there will be almost no performance gain, in many cases even loss in performance.
  • You're already using GAC, because all standard .NET assemblies are actually in GAC and ngened (during installation).
  • Using GAC for your own libraries adds complexity into deployment, I would try to avoid it at all costs.
  • Your users need to be logged as administrators during installation if you want to put something into GAC, quite a problem for many types of applications.

So to sum it all, start simple and if you later see major performance gains if you put your assemblies into GAC and NGEN them, go for it, otherwise don't bother. GAC is more suitable for frameworks where there is expectation for library to be shared among more applications, in 99% of cases, you don't need it.

like image 170
lubos hasko Avatar answered Sep 21 '22 19:09

lubos hasko


Advantage:

  • Only one place to update your assemblys
  • You use a little less hard drive space

Disadvantage:

  • If you need to update only one website, you can't. You may end with the other websites in the webserver broken

Recommendation: Leave the GAC to MS and friends. The gigabyte is very cheap now.

like image 39
Eduardo Molteni Avatar answered Sep 20 '22 19:09

Eduardo Molteni