Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When and when-not to install into the GAC?

When should you install into the GAC and when should you not? (I am referring, really, to installing on a client's machine when they have purchased our product(s)).

  1. I have an assembly that is only going to be used with my one application (GAC or no-GAC)?

  2. I have an assembly that all my applications share (GAC or no-GAC)?

  3. All my applications may use different versions of my assembly (GAC or no-GAC)?

These are three scenarios... but I am sure there are more. I'm not necessarily looking an answer to only these three questions.

Similar question: What are the advantages and disadvantages of using the GAC?

like image 279
Jason Avatar asked Jan 31 '09 05:01

Jason


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.

In which of the following typical scenarios the GAC is best avoided?

In more typical scenarios, however, the GAC is best avoided because it adds the following complications: § XCOPY or ClickOnce deployment is no longer possible; an administrative setup is required to install your application. § Updating assemblies in the GAC also requires administrative privileges.

Which type of assembly should be installed in GAC?

To install an assembly in the GAC, you must give the assembly a strong name. The name is a cryptographic hash-key, or signature. This strong name ensures correct component versioning.

Why should I store my shared assemblies in the GAC?

The system verifies assemblies when they are first installed in the GAC, eliminating the need to verify an assembly each time it is loaded from the GAC. This can improve the startup speed of your application if you load many shared assemblies.


1 Answers

General MS guidelines

  1. no
  2. no
  3. no

GAC is really a repository for Microsoft common .NET libraries. Yes, they let developers use it too, but as a rule of thumb, if you don't need GAC, don't use it. keep things simple and local if it doesn't hurt.

  • I would consider GAC only for performance reasons, for example if you have some huge assemblies, try to place them into GAC and NGEN them. It should significantly increase performance. Microsoft does it for all standard .NET framework assemblies during installation (now you know why that installation takes so long). Paint.NET does it as well (to improve startup time of their app). However most of us don't work on huge frameworks or photoshop competitors, so most of the time, performance gains from having assembly in GAC are minimal. Not worth giving up simple x-copy deployment.

  • Some developers might use GAC to make sure that users with insufficient privileges can't delete or modify their assemblies.

  • For others it might be for versioning reasons but here you should really reconsider. I'm not going to repeat what has been already said, you can read here why.

And don't forget that once you want to deploy into GAC, your installer will need administrator privileges, you can pretty much forget click-once deployment, etc...

like image 58
lubos hasko Avatar answered Oct 08 '22 03:10

lubos hasko