This is one of those things that I commonly forget because it doesn’t crop up too often. Sometimes when deploying a solution to SharePoint 2010 using Visual Studio, you’ll get an error like this:
Error occurred in deployment step ‘Add Solution’: Error: Cannot add the specified assembly to the global assembly cache: MyCompany.Namespace.widget.dll.
There are a few reasons for this. For example, OWSTimer.exe may be using the dll in question or Visual Studio may have it locked. However, rather than stopping and starting services indiscriminately and restarting Visual Studio, we can find out exactly which process is causing us grief by using the TaskList application.
Open up a command prompt and type:
tasklist /M MyCompany.Namespace.widget.dll
You’ll see results such as:
Image Name PID Modules
========================= ======== ============================================
WebAnalyticsService.exe 2040 MyCompany.Namespace.widget.dll
w3wp.exe 4716 MyCompany.Namespace.widget.dll
w3wp.exe 1164 MyCompany.Namespace.widget.dll
Armed with this info we know what to shut down to resolve the issue. Another SharePoint mystery unravelled!