如何调试一个被引用的DLL [英] How to debug a referenced dll

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

问题描述

我的问题的关注与Visual Studio 2008,但我想这应该是相同的VS2005

My question concerns with Visual Studio 2008, although I suppose it should be that same in VS2005

我在我的工作区两个解决方案,比方说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的code为好。 Visual Studio是无法加载code这些类(没有可用于当前位置没有源$ C ​​$ C),我只能查看拆卸,这是没有用的。

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.

我知道要调试类从溶液中的唯一的办法是通过运行解决方案B,分离所有进程(在调试菜单项),并从溶液中的附加程序。

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(为此我有源$ C ​​$ C)?

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

解决方案:我的错误是,我认为,一个项目只能是一个单一的解决方案的一部分。事实上,一个项目可以是任何数量的解决方案的一部分。

当你需要引用旧的项目,你只需简单地把项目添加到解决方案。这可以通过右键单击在Solution Explorer的新解决方案>添加>现有项目完成。

然后,你就可以添加项目引用。正如其他人写的,你应该完全避免使用DLL引用到自己的code(或其他code,你可能需要更改和调试)。

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

A very good reference to how solutions should be designed can be found in MSDN.

推荐答案

如果你有一个项目的参考,就应该立即工作。

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

如果它是一个的文件(DLL)的参考,则需要调试符号(下称PDB文件)是在同一文件夹中的DLL。检查您的项目正在生成调试符号(项目属性=>生成=>高级=>输出/调试信息=全);如果你有复制的的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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