Error: Cannot add the specified assembly to the global assembly cache

Yesterday I was not able to deploy my solution to my sharepoint development server, with the error message

Error occurred in deployment step ‘Add Solution’: Error: Cannot add the specified assembly to the global assembly cache: MyLibrary.dll.

As the error message did not tell me why this happened or how I could fix it, I asked google. I found a lot of suggestions regarding permissions which were not relevant in my case. It turned out to be an easy fix however:

Manually uninstall the dll from the GAC!
In details: Start, run, %windir%\assembly\, find your dll, right click and choose uninstall.

In my case, I was not allowed to uninstall it because it was in use, so with some help from the process explorer from Sysinternals I found (click Ctrl+F and search) that owstimer, web analytics service and four instances of visual studio (devenv) were all using my dll. Restarting the services and closing my visual studio sessions allowed me to uninstall the dll from the GAC, and deployment worked fine again after that.

Advertisements

About Øystein Garnes

Software Project Manager, former .Net and SharePoint 2010 developer, husband, Boston Terrier owner, amateur caveman chef, amateur genealogist, cross country skier, food blogger.
This entry was posted in SharePoint and tagged , . Bookmark the permalink.

13 Responses to Error: Cannot add the specified assembly to the global assembly cache

  1. You don’t need Process Explorer, the following command line command will also do the work:

    PS C:\Users\bratuk> tasklist /M MySuperfancy.dll

    Restarting VS and stopping owstimer will probably fix most of these issues i guess.

  2. Hi Brage, thanks for the tip! I’ll try that next time I run into this 🙂

    Øystein

  3. Bercan Radu says:

    Hi,

    I had this problem also and process explorer helped me. TaskList was not showing ReportingServicesService that also had a lock on the DLL.

    Radu

  4. Pål says:

    Thanks! uninstalling manually from gac helped me (had to do a iisreset to unlock the file first)

  5. Simi says:

    Try doing an IISreset , clear your Temporary Files Folder and if that still doesnt work, close your VS and restart your VS.It did work for me. Thank you.Simi

  6. Harsha Vardhan says:

    Simi, Thanks for your suggestion.. it worked like a charm 🙂

  7. Pradeep Sharma says:

    Thanks Øystein Garnes… It worked….

  8. Brandon says:

    The iisreset was the solution for me too!

  9. Rich says:

    rebooting worked… and allowed me to get a coffee

  10. FK says:

    The iisreset was the solution for me too!

  11. Alexey says:

    owstimer service stopping helped me.

  12. Matt Connolly says:

    I have solved this issue by closing Visual Studio and doing nothing else. IIS restarts did not make a difference.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s