如何在 Visual Studio 2012 中加载符号 [英] How to load symbols in Visual Studio 2012

查看:49
本文介绍了如何在 Visual Studio 2012 中加载符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调试我的应用程序时,我看到消息:

When I am debugging my app I see messages:

无法找到或打开 PDB 文件

cannot find or open the PDB file

我似乎记得能够在调试应用程序时指定 PDB 文件的位置.我怎样才能做到这一点?我使用的是 Visual Studio 2012.

I seem to remember being able to specify the location of the PDB file while debugging the app. How can I do this? I'm using Visual Studio 2012.

推荐答案

添加符号位置

打开设置:工具->选项->调试->符号并添加您的.PDB文件所在的目录.

Adding Symbols Location

Open Settings: Tools->Options -> Debugging -> Symbols and add directory, where your .PDB files are located.

此菜单所在的 Visual Studio 界面的屏幕截图

您可以为每个项目添加自定义路径,也可以编辑公共路径,Visual Studio 将在其中保存所有 .pdb 缓存.

You can add custom path, like for each project, and also you can edit common path, where Visual Studio will save all .pdb cache.

我在每个项目中进行了编译后事件,将所有 .pdb 复制到一个文件夹中,这样我就将所有内容放在一个地方.但是您可以单独存储它,我发现这不太方便,因为每次编辑位置列表时都需要.

I made in each project post-compile event, which copy all .pdb to one folder, by this i have all in one place. But you can store it separately, which i found not so convenient, as it require each time edit list of locations.

将 .pdb 和 .dll 复制到 Symbols 缓存位置的调试后脚本示例:

xcopy /Y /R "$(TargetDir)$(ProjectName).pdb" "D:\VS_CACHE\"
xcopy /Y /R "$(TargetDir)$(ProjectName).dll" "D:\VS_CACHE\"

解决未找到符号的问题

当您处于调试模式时,由于某种原因找不到符号,可能是由于多种原因:

  1. 您在符号缓存中有 .pdb,但它已经过时(如果是这种情况,您可以得到,如果您在代码中放置断点并将其悬停)
  2. 您有多个使用这部分代码的 .dll (如果是这种情况,您可以得到,如果您在代码中放置断点并将其悬停)
  3. 符号未加载,在这种情况下,您可以通过以下方式进行检查:调试-> Windows -> 模块并尝试加载所需的模块.
  1. You have .pdb in Symbols cache, but it's outdated (you can get if this a case, if you put breakpoint in code and hover it)
  2. You have multiple .dll which use this part of code (you can get if this a case, if you put breakpoint in code and hover it)
  3. Symbols not loaded, in this case you can check it by going to: Debug-> Windows -> Modules and trying to load needed module.

Visual Studio 界面模块截图 -> 加载符号

要将 VS Debugger 重新附加到正在运行的应用程序,我建议使用这个免费的 Visual Studio 附加组件(支持 VS 2015):

To re-attach VS Debugger to running application, i recommend to use this free Visual Studio add-on (support VS 2015):

重新连接:visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae

ReAttach: visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae

它会为您节省很多时间!:)

It will save you a lot of time! :)

这篇关于如何在 Visual Studio 2012 中加载符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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