如何调试引用的dll(具有pdb) [英] How to debug a referenced dll (having pdb)

查看:380
本文介绍了如何调试引用的dll(具有pdb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作区中有两个解决方案,分别是A和B.

I have two solutions in my workspace, say A and B.

解决方案A是一个较旧的项目,我前段时间完成了编码. 在解决方案B中,我需要使用解决方案A中的一些类.为此,我添加了对解决方案A中一个项目的dll的引用.

Solution A is an older project which I finished coding some time ago. In solution B, I need to use some classes from Solution A. To do so, I add a reference to the dll of one of the projects in solution A.

问题是当我尝试调试时.我也希望能够进入A的代码. Visual Studio无法加载这些类的代码(当前位置没有可用的源代码."),我只能查看反汇编,这没有用.

The problem is when I try to debug. I want to be able to step into A's code as well. Visual studio is not able to load the code for these classes ("There is no source code available for the current location.") and I can only view the disassembly, which is not useful.

我知道从解决方案A调试类的唯一方法是运行解决方案B,分离所有进程(在调试"菜单项中),然后从解决方案A附加进程.

The only way I know to debug classes from solution A is by running solution B, detach all processes (in the Debug menu item) and attach the process from solution A.

但是,这很不方便,我只能一次调试A或B.

However, this is very inconvenient and I can only debug A OR B at once.

有没有办法进入所引用的dll代码(我确实有其源代码)?

Is there a way to allow stepping into the code of referenced dlls (for which I do have the source code)?

解决方案::我的错误是我认为一个项目只能成为单个解决方案的一部分.实际上,一个项目可以成为许多解决方案的一部分.
当您需要引用旧项目时,只需将项目添加到解决方案中即可.通过在解决方案资源管理器>添加>现有项目中右键单击新解决方案来完成此操作.
然后,您将能够添加项目参考.正如其他人所写的那样,您可能应该完全避免对自己的代码(或其他可能需要更改和调试的代码)使用dll引用.

Solution: My mistake was that I thought that a project can only be part of a single solution. In fact, a project can be part of any number of solutions.
When you need to reference the old project, you should simply add the project to the solution. This is done by right clicking the new solution in the Solution Explorer > Add > Existing Project.
Then, you'll be able to add the project reference. As others wrote, you should probably completely avoid using dll references to your own code (or other code you might need to change and debug).

可以在 MSDN .

推荐答案

如果您有项目引用,则应立即使用.

If you have a project reference, it should work immediately.

如果它是一个文件(dll)引用,则需要将调试符号("pdb"文件)与dll放在同一文件夹中.检查您的项目是否正在生成调试符号(项目属性=> Build => Advanced => Output/Debug Info = full);如果您已经复制了 dll,则将pdb放入其中.

If it is a file (dll) reference, you need the debugging symbols (the "pdb" file) to be in the same folder as the dll. Check that your projects are generating debug symbols (project properties => Build => Advanced => Output / Debug Info = full); and if you have copied the dll, put the pdb with it.

如果您不想复制任何文件,也可以直接在IDE中加载符号,但这会增加工作量.

You can also load symbols directly in the IDE if you don't want to copy any files, but it is more work.

最简单的选择是使用项目引用!

The easiest option is to use project references!

这篇关于如何调试引用的dll(具有pdb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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