visual-studiodebuggingvisual-studio-2003

PDB remains open after debugging (Windows 10, Visual Studio)


Our previous development systems used Windows XP and Windows 7. Debugging C++ DLLs from Visual Studio worked great.

A recent move to Windows 10 has resulted in an annoying problem. We can debug once (using F5), but the 2nd time results in a linker error:

MyProg fatal error LNK1201: error writing to program database 'MyProg.pdb'

Trying to delete the .pdb manually in Explorer while Visual Studio is still open results in the error:

The action can't be completed because the file is open in devenv.exe

It doesn't matter whether you hit a breakpoint or not. Just start debugging once results in the problem. Re-starting Visual Studio resolves the issue (in the sense that you can debug once, but then you get the problem again).

If relevant:


Solution

  • After hunting around for several hours some related, but unanswered, questions were found. Following suggestions in this MSDN article, along with some debugging of my own, this solution works:

    ...and now you don't need to restart Visual Studio to debug a 2nd time!

    From comments, this works with multiple versions of Visual Studio on multiple versions of Windows.

    Update

    A more radical solution is described here which involves replacing a core Visual Studio DLL (NatDbgDE.dll). This solution only works for Visual Studio 2003 SP1, though.