Currently we use the Global Assembly Cache (GAC) to install shared assemblies which are called by a number of different applications; however articles such as the infamous “Avoid the GAC” http://www.sellsbrothers.com/spout/#Avoid_the_GAC article have made me question the usefulness of this approach.
To summarise our deployment we have perhaps 40 or so assemblies which are referenced by a number of different applications namely.
- A windows service.
- An ASP application.
- A thick client windows application.
- A .NET console application.
All applications use the same set of core assemblies to perform most of the functions e.g. core invoicing and ordering components as well as components which are applicable across many different functional areas.
Every time we rebuild and deploy a new component e.g. assembly A which has upgraded from say 184.108.40.206 to 220.127.116.11 we ship a new publisher policy assembly which redirects 18.104.22.168 to 22.214.171.124 references to 126.96.36.199 and obviously also re installs the new updated assembly into the GAC. E.g. 188.8.131.52 may fix an issue in the database where a stored procedure is being used with an incorrect parameter order causing data integrity issues.
This deployment works well in that components which are shared amongst all applications only need to be installed in one place. In the future we may provide breaking components with major functionality changes e.g. we introduce a new assembly A 184.108.40.206 version which may have breaking changes. In this case we envisage we may update the publisher policy with multiple redirections setup such as
220.127.116.11 - 18.104.22.168 ---> 22.214.171.124
126.96.36.199 - 188.8.131.52 ---> 184.108.40.206
In this way we can support side by side versioning of both sets of assemblies. We make a statement with the publisher policy that version increments containing changes across 220.127.116.11 – 18.104.22.168 are compatible and are needed for all applications referenced assemblies in this range however applications which reference new assemblies in the range 22.214.171.124 + are breaking and should reference a different assembly.
Currently we use the GAC to deploy all our assemblies and it seems to work well. The GAC was chosen because of the following benefits in order of importance:
- Ease of deployment. When shared assemblies are updated they only have to be updated in one location as opposed to four directories namely system32, windows\system32\inetsrv, c:\program files\Tranmit\Transaction Engine and C:\program files\Tranmit\Products\SprintLog. Deploying the assemblies to more than one location is obviously more error prone and an additional burden on an administrator installing patches.
- Performance. When strongly named assembly files are loaded from a location other than the GAC the CLR compares hash values when the assembly is loaded. A hash of the file is performed every time an application executes. In addition any referenced assemblies in that assemblies manifest are also hashed and compared. This performance hit is required to ensure that the assembly file’s content hasn’t been tampered with.
- Security. The GAC is only accessible to those users with sufficient privilege.
- Traced references. Assemblies installed in the GAC can be added with a reference to the application. This prevents assemblies being removed accidentally and breaking client applications dependent on them.
Chris Sells author of the “Avoid the GAC” article actually agreed the GAC was the best choice in our case however I am keen to hear other peoples’ opinions on this interesting topic. I would certainly consider changing to XCOPY deployment if there is good reason.