How do I – Solve the – Unexpected error creating debug information file .pdb. The process cannot access the file because it is being used by another process. – compiler error?

Written by Cornelius J. van Dyk on . Posted in How Do I...

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:

  1. Open Windows Explorer.
  2. Browse to the C:\Program Files\Process Explorer location, or any other alternative location where you may have installed Process Explorer to.
  3. image
  4. Double click “Procexp.exe” to launch Process Explorer.
  5. 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.
  6. In the top menu, click the “Find” menu item.
  7. 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.
  8. image
  9. In the Process Explorer Search dialog window, enter the name of your DLL, or in our case, the name of our .pdb file.
  10. Click “Search” or press “Enter”.
  11. image
  12. Process Explorer displays the process that has the lock and wouldn’t you know it, it’s Visual Studio itself. 
  13. Double click on the “devenv.exe” line.
  14. Process Explorer now closes the dialog window and the “devenv.exe” item is added to the displayed list.
  15. Right click the “devenv.exe” line in the displayed list.
  16. image
  17. On the popup menu, click the “Close Handle” menu option.
  18. 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. 
  19. image
  20. After closing the handles, we return to Visual Studio and press F5 or click Rebuild and tada!  
  21. image

Happy coding!



Tags: , , , , , ,

Trackback from your site.

Cornelius J. van Dyk

Born and raised in South Africa during the 70's I got my start in computers when a game on my Sinclair ZX Spectrum crashed, revealing it's BASIC source code. The ZX had a whopping 48K of memory which was considered to be a lot in the Commodore Vic20 era, but more importantly, it had BASIC built into the soft touch keyboard. Teaching myself to program, I coded my first commercial program at age 15.

After graduating high school at 17, I joined the South African Air Force, graduating the Academy and becoming a Pilot with the rank of First Lieutenant by age 20. After serving my country for six years, I made my way back into computer software.

Continuing my education, I graduated Suma Cum Laude from the Computer Training Institute before joining First National Bank where my work won the Smithsonian Award for Technological Innovation in the field of Banking and Insurance. Soon I met Will Coleman from Amdahl SA, who introduced me to a little known programming language named Huron/ObjectStar. As fate would have it, this unknown language and Y2K brought me to the USA in 1998.

I got involved with SharePoint after playing around with the Beta for SharePoint Portal Server 2003. Leaving my career at Rexnord to become a consultant in 2004, I was first awarded the Microsoft Most Valuable Professional Award for SharePoint in 2005, becoming only the 9th MVP for WSS at the time. I fulfilled a life long dream by pledging allegiance to the Flag as a US citizen in 2006. I met the love of my life and became a private consultant in 2008. I was honored to receive my ninth MVP award for SharePoint Server in 2013.

Leave a comment

You must be logged in to post a comment.