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


6 thoughts on “Installing and uninstalling DLL’s into the GAC

  1. Parvez Ghumra April 4, 2013 / 8:18 am

    Nice post Ben!

    Probably worth writing a custom installer for such DLLs so you/your client can easily install/uninstall the assemblies using a ‘Next, Next, Finish’ type process.

    Also, in my experience, I’ve had to restart the Microsoft Dynamics CRM Asynchronous Processing Service, the Microsoft Dynamics CRM Asynchronous Maintenance Service and the Microsoft Dynamics CRM Sandbox Processing Service after the installation/update in order to ensure that any plugins and custom workflow activities pick up the new DLLs from the GAC, as well as doing an IISRESET on the web server. 🙂


  2. Hosk April 4, 2013 / 8:28 am

    That is a very good point, it’s definitely worth doing an iisreset, which means you have to inform everyone using the system.

    I had a folder and bat file – semi automated for development environment


  3. Eni Elezi April 4, 2013 / 10:25 am

    …also batch files can be used to quickly install one or multiple dlls. The one I am using:
    echo registering to GAC started..

    gacutil.exe /if PostSharp.dll
    gacutil.exe /if MyAssemly.Xrm.Common.dll

    set /p isexit=registering to GAC completed.


  4. AdrianR April 4, 2013 / 2:22 pm

    A note on IISRESETing – if you going to do that then you should use the /noforce switch, this allows IIS to gracefully shutdown processes and save to disk any configuration changes.

    A safer option, and less disruptive for users is just recycling the CRM app pool. It does the same job for plugins but doesn’t affect sites using other app pools and is quicker for CRM to come back up.


  5. John April 5, 2013 / 2:51 pm

    Just use gacutil /if and you won’t have to worry about the duplicate issue. It will replace the existing dll if it’s already in the GAC.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.