Tuesday, May 10, 2011

Does your assembly actually belong in the GAC?

In many cases, NO.
Many developers believe that “GACing” their assemblies is always the proper way to deploy them. In reality, privately deploying your assemblies (even if they’re strongly named) is a better option.
Assembles that are not shared by other applications should not be installed in the GAC. In fact, if only a few applications need to share it, you can still deploy privately. This provides for better isolation as well as easier upgrades via shadow copy. This is especially important with ASP.Net applications. If you install an updated assembly in to the GAC, the application pool needs to be bounced in order for the new version of the assembly to be loaded. If you deploy the new assembly to the Bin (or elsewhere), your application will finish handling in-process requests with the old version and pick up new requests with the new version. No need to restart, reset or bounce anything.

Note: If you're running a .Net version prior to .Net 2, strongly named ASP.Net assemblies must be "GACed" to avoid a locking bug.
If several applications will be sharing the assembly then GAC it for sure.

No comments:

Post a Comment