C# Visual Studio:调试引用的 DLL,我在另一个 SLN 中有源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16546703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio: Debugging a referenced DLL, I have source in another SLN
提问by Martin
I am trying to debug a project that has a reference to a DLL that I added, the DLL is stored in an external directory and I just added a reference. Now of course I can debug my project but the line that calls a method on my other dll I can't step into it, i.e. F12.
我正在尝试调试一个项目,该项目引用了我添加的 DLL,该 DLL 存储在外部目录中,而我刚刚添加了一个引用。现在我当然可以调试我的项目,但是在我的其他 dll 上调用方法的那一行我无法进入它,即 F12。
One way I was able to do this was to add my project (dll) as an existing project to my solution and replace the referenced dll to use the attached project rather than a file on disk.
我能够做到这一点的一种方法是将我的项目 (dll) 作为现有项目添加到我的解决方案中,并替换引用的 dll 以使用附加的项目而不是磁盘上的文件。
But what a mess, I am sure there is a cleaner way?
但是真是一团糟,我确定有更清洁的方法吗?
I seem to remember if I copy some PDB files or something but i can't remember. And Do i need to open 2 copies of visual studio, 1 for my main project and 1 for my referenced DLL??
我似乎记得我是否复制了一些 PDB 文件或其他东西,但我不记得了。我是否需要打开 2 个 Visual Studio 副本,1 个用于我的主项目,1 个用于我引用的 DLL?
采纳答案by Kna?is
Rebuild the second solution in Debug mode on your own machine (so that file paths in that PDB are specific to your machine).
在您自己的机器上以 Debug 模式重建第二个解决方案(以便该 PDB 中的文件路径特定于您的机器)。
Copy boththe .DLL and .PDB files to your references folder. Visual Studio will pick up the .PDB file automatically and use the file paths to show source.
复制都将.dll和.pdb文件到您的引用文件夹。Visual Studio 将自动选取 .PDB 文件并使用文件路径来显示源。
You can also use Symbol Server and Source Server to achieve this when the referenced assembly is built elsewhere: http://msdn.microsoft.com/en-us/library/vstudio/ms241613.aspx
当在其他地方构建引用的程序集时,您还可以使用符号服务器和源服务器来实现此目的:http: //msdn.microsoft.com/en-us/library/vstudio/ms241613.aspx
回答by Cool Blue
When you do a Debug build, all of the dll and pdb files are established in the host project. So there should be no need to copy files manually.
进行调试构建时,所有 dll 和 pdb 文件都在宿主项目中建立。所以应该不需要手动复制文件。
Right-Click on the Solution, select Add/Existing Project... Navigate to the Class lib folder and select the proj file (e.g. myproj.csproj). The files are not copied, just referenced and you can open the source for the class in the IDE and set breakpoints in the normal way and it just works.
右键单击解决方案,选择添加/现有项目... 导航到 Class lib 文件夹并选择 proj 文件(例如 myproj.csproj)。这些文件不会被复制,只是被引用,您可以在 IDE 中打开该类的源代码并以正常方式设置断点,它就可以正常工作。
回答by Dilip Jangid
I got the solution by doing the below
我通过执行以下操作得到了解决方案
Try disabling Just My Code (JMC).
尝试禁用仅我的代码 (JMC)。
Tools -> Options -> Debugger Uncheck "Enable Just my Code"
工具 -> 选项 -> 调试器取消选中“仅启用我的代码”
回答by Aamol
I had same problem which I resolved by cleaning and rebuilding the solution . It will correct references in .pdb files to locate and hit the break point in second project.
我有同样的问题,我通过清理和重建解决方案解决了这个问题。它将更正 .pdb 文件中的引用,以在第二个项目中定位并击中断点。

