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

允我心安 提交于 2019-11-28 14:23:04

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:

  • Download FreePDB, a script written by MSDN user Toni76 (thanks Toni!)
  • Copy this script to a local folder (say C:\Apps\FreeDPB)
  • Download the latest version of SysInternals tool Handle (currently v4.21)
  • Copy handle.exe to C:\Apps\FreeDPB
  • NB! From the command line, run handle /? once. This is to agree the EULA. The script will not work if you skip this step!
  • Open Visual Studio, then Project > Properties > Build Events > Pre-Build Event
  • Set Command Line to C:\Apps\FreeDPB\freepdb $(ProjectName)
  • Set Description to Delete lock on PDB

...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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!