I have two VS solutions. Solution A_sol is C++/C# projects. Solution B_sol has project B_proj that is C# wrapper around C++ *.dll generated by B_proj project in A_sol.
How do I debug A_proj from B_proj ?
UPDATE: one of the projects in B_sol is an executable.
-
Once the code is already running it doesn't really matter if it's exe or library code - it's all the same ;)hoodaticus– hoodaticus2017-07-19 21:27:43 +00:00Commented Jul 19, 2017 at 21:27
3 Answers
How do I debug A_proj from B_proj ?
If I understood you correctly, A_proj is a C++ project. Below I will give my advice based on this assumption.
Note that it doesn't really matter from which project/solution you start debugging as long as you have the debug info (in other words, for C++ projects - if Visual Studio is able to pick up PDB's).
So you may either run your executable from the solution, or, as suggested by @hoodaticus in his answer, attach to the process which is already running. Whether your project is executable or not, you will be able to attach to it as long as:
- DLL is loaded into that process
- You have the PDB file that matches the DLL (generated during the build)
So I'll just repeat the same advice
In the other project, do Debug > Attach to Process > pick your process from the list.
but I'll add that you have to pay attention to select "Debug these code types -> Native" for the process that contains your C++ dll. This part is often missed and confuses people, taking some time to discover (personally, I often get into it) 
Hope that helps.
Comments
- Run the process you want to debug outside the debugger.
- In the other project, do Debug > Attach to Process > pick your process from the list.
2 Comments
A_sol(one that generates C++ .dll) is not an executable solution. it is purely a library solution.To be able to debug by pressing F5 (rather than having to pick your process each time),
- Right-click the startup project (the EXE) and choose Properties
- In the Debug tab, select Enable native code debugging
The above steps are from this tutorial: https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-managed-and-native-code?view=vs-2019