调试后(Windows 10,Visual Studio)PDB保持打开状态 [英] PDB remains open after debugging (Windows 10, Visual Studio)

查看:116
本文介绍了调试后(Windows 10,Visual Studio)PDB保持打开状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们以前的开发系统使用Windows XP和Windows7.从Visual Studio调试C ++ DLL效果很好.

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

最近迁移到Windows 10导致了一个令人讨厌的问题.我们可以调试一次(使用F5),但是第二次会导致链接器错误:

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'

尝试在Visual Studio仍处于打开状态时在资源管理器中手动删除.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

是否达到断点都没有关系.一旦出现问题,只需开始调试即可.重新启动Visual Studio可以解决此问题(从某种意义上说,您可以调试一次,但随后又会遇到问题).

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

如果相关:

  • x86 Visual Studio 2003.NET
  • 定位到另一个x86应用程序
  • x64 Windows 10 Pro v1803

推荐答案

经过数小时的搜寻,他们发现了一些相关的内容,但未得到答案,发现了问题.遵循

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:

  • 下载 FreePDB ,该脚本由MSDN用户句柄(当前为v4 .21)
  • handle.exe复制到C:\Apps\FreeDPB
  • 注意!在命令行中,一次运行handle /?.这是同意EULA.如果您跳过此步骤,脚本将无法正常工作!
  • 打开Visual Studio,然后依次单击项目">属性">构建事件">预构建事件"
  • Command Line设置为C:\Apps\FreeDPB\freepdb $(ProjectName)
  • Description设置为Delete lock on PDB
  • 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

...现在您无需重新启动Visual Studio进行第二次调试!

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

从注释来看,这可以在Windows的多个版本上使用Visual Studio的多个版本.

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

此处描述了一种更彻底的解决方案,其中涉及替换核心Visual Studio DLL (NatDbgDE.dll).但是,该解决方案仅适用于Visual Studio 2003 SP1.

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.

这篇关于调试后(Windows 10,Visual Studio)PDB保持打开状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆