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.