As a SharePoint Developer, you may run across this error at some point.
It is most common when you’re trying to recompile a SharePoint binary, from a
Visual Studio session ON the actual SharePoint server. Of course, in most normal situations, it’s unthinkable to run the compiler on the server, but as SharePoint developers, we know there is no other way to code for the platform so it’s pretty much
SOP for us.
The problem lies in the locks that are taken by the compiler process on the debug info file. Often the locks are taken by your last debug session and unfortunately the locks aren’t always released, even though you’re the same user from the same application. Call it a multi threading anomaly or something. Whatever it is, this happens in Visual Studio 2008.
Enter
Process Explorer! This little gem by
Mark Russinovich from
SysInternals, has been around for a long time, now in it’s
12th version. Microsoft bought SysInternals a couple of years ago, and with it, Mark’s great mind. I must say, it was probably one of the smartest acquisitions that
Redmond has ever made. But I digress. So, if you have Process Explorer installed (if you don’t, download it now and do so), it generally lives in the C:\Program Files\Process Explorer folder. To unlock your files and resume your compilation, follow these easy steps:
Open Windows Explorer.
Browse to the C:\Program Files\Process Explorer location, or any other alternative location where you may have installed Process Explorer to.
-
Double click “Procexp.exe” to launch Process Explorer.
Once Process Explorer opens, it will display a list of all active processes on your system. Odds are that your .pdb file is NOT shown here.
In the top menu, click the “Find” menu item.
In the drop down menu, click the “Find Handle or DLL” menu option. NOTE: If you’re a shortcut kinda guy or gal, you could have accessed this option with the “Ctrl+P” keyboard hotkey combo.
-
In the Process Explorer Search dialog window, enter the name of your DLL, or in our case, the name of our .pdb file.
Click “Search” or press “Enter”.
-
Process Explorer displays the process that has the lock and wouldn’t you know it, it’s Visual Studio itself.
Double click on the “devenv.exe” line.
Process Explorer now closes the dialog window and the “devenv.exe” item is added to the displayed list.
Right click the “devenv.exe” line in the displayed list.
-
On the popup menu, click the “Close Handle” menu option.
Process Explorer will display a warning message noting stability and crashes that may be caused by closing the handles on this file. Of course we understand this and we click “Yes”. Or alternatively, we don’t understand but as a Windows user, we blindly click “Yes” to just make the popup go away.
-
After closing the handles, we return to Visual Studio and press F5 or click Rebuild and tada!
-
Happy coding!
CheersC