如何调试(步入)我的项目中引用的类库,并具有.pdb和源代码? [英] How to debug (step into) a class library referenced in my project and has .pdb and source code?

查看:398
本文介绍了如何调试(步入)我的项目中引用的类库,并具有.pdb和源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio(2015)中调试打开的解决方案/项目时,我想调试(进入)一个位于一个引用程序集中的方法调用。程序集具有.pdb(复制本地)和源代码。这个程序实际上也是我的类lib项目,而不是在当前的解决方案中,而不是在另一个解决方案中。



我知道调试这个程序集的微不足道的解决方案将是添加它的项目到目前的解决方案,而不是引用它,那么调试经验将是无缝的。然而,由于某些原因,在我的情况下这不是太有效率,例如有许多程序集(数十个),我应该添加,我不想以一个巨大的解决方案结束。



我已经完成/尝试了到目前为止:




  • 我已经取消选中只是我的代码

  • 我检查了另一个程序集的.pdb是否被复制到我当前项目的输出文件夹。

  • 尝试在之前设置一个断点打电话,然后将进入。没有成功,通话仅仅是

  • 我想要调试的程序集作为一个NuGet软件包(不是一个简单的浏览参考)。仍然是真的,这是我的类lib项目,附带.pdb,源代码在我的本地磁盘中可用。

  • 查看窗口 - >调试 - >模块:符号状态:符号加载。用户代码:N / A。符号文件位置是一个Temp Asp文件。 (它是一个ASP.NET MVC应用程序)

  • 由于它来自NuGet软件包,其构建是一个版本构建,但目前尚未优化,而具有最新的.pdb



我记得这个调试功能有时会自动地工作,但是现在它不会。 >

我缺少什么?

解决方案

这种经历的最常见原因是:


  1. 启用我的代码(tools-> options-> debugging)

  2. 不匹配的PDB

  3. 不匹配的来源

你排除了1,所以检查其他2:



打开调试 - > Windows->模块并查找您遇到问题的程序集。确保从您期望的位置加载,具有期望的版本,检查是否加载了PDB。您可能需要尝试加载/重新加载PDB以查看VS是否对其所在的PDB感到满意。



如果PDB匹配VS应该开始询问源位置。关于源的信息是PDB的一部分,所以它会让你知道源是否匹配(有选项允许加载不匹配的源文件,但你会得到有趣的调试过期)。



请注意,如果您为RELEASE创建库,那么它将被优化,对于某些功能,由于在JIT时间内联或编译时间较短的死码(如 if(false)分支)。为了获得最佳的到期性,请确保使用带有匹配PDB的DEBUG程序集,并确保尽早使用调试器选项中的禁止加载优化。


When debugging the opened solution/project in Visual Studio (2015) I would like to debug (step into) a method call which is located in one of the referenced assemblies. The assembly has .pdb (copied local) and source code. This assembly actually is also my class lib project, but not in the current solution, instead in an other solution.

I know the trivial solution to debug this assembly would be adding its project to the current solution instead of referencing it, then debugging experience would be seamless. However for some reasons this would not be too efficient in my case, for example there are many assemblies (dozens) which I should add and I do not want to end with a giant solution.

What I've done/tried so far:

  • I've unchecked Just my code
  • I've checked that .pdb for the other assembly is copied to my current project's output folder.
  • Tried to set a breakpoint just before the call, then step into. No success, the call was just stepped over.
  • The assembly I would like to debug is coming as a NuGet package (not a simple browsed reference). Still true, it's my class lib project, comes with .pdb, and the source code is available in my local disk.
  • Looked at Window->Debug->Modules: Symbol status: Symbols loaded. User Code: N/A. Symbol File location is a Temp Asp Files. (It is an ASP.NET MVC application)
  • Because it is coming from a NuGet package its build is a Release build, but currently not optimized, and has the up to date .pdb

As I recall this debugging feature was sometimes surprisingly worked automagically, however now it does not.

What am I missing?

解决方案

Most common reasons of such experience are:

  1. enabled "my code only" (tools->options->debugging)
  2. mismatched PDBs
  3. mismatched sources

You've ruled out 1, so to check the other 2:

Open Debug->Windows->Modules and find assembly you are having problem with. Make sure it is loaded from location you expect, has version you expect, check if PDBs are loaded. You may need to try load/reload PDB to see if VS is happy with PDB it located.

If PDBs are matching VS should start asking about source location. Information about source is part of PDB so it will let you know if source matches or not (there is option to allow loading mismatched source files, but you'll get funny debugging expirience).

Note that if you library build for RELEASE it will be optimized and for some function you'll not be able to debug them at all due to inlining at JIT time or compile time optimizations of dead code (like if (false) branches). For best expirience make sure to use DEBUG assembly with matching PDB and make sure to attach early with "suppress optimizations on load" in debugger options.

这篇关于如何调试(步入)我的项目中引用的类库,并具有.pdb和源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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