Installing and uninstalling DLL’s into the GAC

 

There will probably come a time in every CRM developers life when they have to install a DLL into the GAC.

The reason you might want to do this is so you code can access the dll’s and methods without having to have the DLL included with your code.  A good example of this is if you have some code which is used in all of your CRM plugins, you can load the dll into the GAC and then all the plugins will be able to access it.

This can only be done using CRM on premise because you can’t do it with CRM online because you can’t load dll’s into the GAC and also because the online plugins are in the sandbox they are not allowed to call dll’s and external code.

To install dll’s into the GAC you have to use the gacutil, which is usually packaged in with Visual Studio.

There is one odd and tricky thing to watch out for, the code for installing/uploading a dll is different from the instruction to uninstall.  It’s not very different which makes it all the more tricky.

You have to use the command line and call the gacutil.exe from the command line, the line below installs a dll into the GAC.

gacutil /i Common.PluginCode.dll

notice you put /i and then the name of the dll with the dll affix.

to uninstall he same dll

gacutil /u Common.PluginCode

its backslash /u and the name of the dll (without the dll affix)

Recently I got this muddled and kept the .dll on the uninstall instruction.  So I then ended up installing a duplicate DLL into the GAC which caused problems, so beware.

 

if would like a more professional explanation about installing into the GAC click the link below

http://msdn.microsoft.com/en-gb/library/ex0ss12c(v=vs.80).aspx