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)).
I have an assembly that is only going to be used with my one application (GAC or no-GAC)?
I have an assembly that all my applications share (GAC or no-GAC)?
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?
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 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.
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.
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.
General MS guidelines
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With