Reputation: 24308
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.
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.
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??
Upvotes: 75
Views: 72084
Reputation: 16
Visual Studio 2022 added a new top-level node: External Sources
to solution explorer, which you will find while in debug mode. You can look at all the loaded dlls from there. You can also look at the loaded modules from Debug -> Windows -> Modules
in debug mode. From there, right click on your desired dll, and click open file location
, and then copy the pdb file to that location. This should allow you to step into any methods of the external dll.
Reference: https://devblogs.microsoft.com/visualstudio/debugging-external-sources-with-visual-studio/
Upvotes: 0
Reputation: 1199
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.
Upvotes: 1
Reputation: 764
I got the solution by doing the below
Try disabling Just My Code (JMC).
Tools -> Options -> Debugger Uncheck "Enable Just my Code"
Upvotes: 18
Reputation: 6476
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.
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.
Upvotes: 0
Reputation: 21485
Rebuild the second solution in Debug mode on your own machine (so that file paths in that PDB are specific to your machine).
Copy both the .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.
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
Upvotes: 85