Tuesday, 4 July 2017

Assemblies 03 GAC

GAC stands for Global Assembly Cache, its a machine wide library for storing assemblies. All assemblies in the GAC must be strongly named, that is signed. Generally you want to avoid installing things into the GAC and if you can leave your assemblies as Private (deployed with your exe in you an application folder) you should. Now one possible reason to deploy to the GAC is if your assembly is referenced from multiple projects.

In production you want to use an installer such as windows installer 2.0 In dev we use a visual studio command line
  • Add: gacutil –i [assembly name]
  • Remove: gacutil –u [assembly name]
If your project references an assembly, but another version of the same assembly is deployed to the GAC, the one located in the GAC trumps the private one.

DLL hell is when dll's got overwritten:

  • accidentally - the publisher deploys a new or older dll that's incompatible with a program 
  • coincidentally - a different publisher has a dll with the same name. 
  • maliciously - a "Bad Person" overwrites a dll for bad reasons. 

Strongly naming our assemblies free's us from DLL hell, but it's good to know when senior colleagues talk about how tough it was in the old days.