1

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.

1
  • Once the code is already running it doesn't really matter if it's exe or library code - it's all the same ;) Commented Jul 19, 2017 at 21:27

3 Answers 3

3

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:

  1. DLL is loaded into that process
  2. 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) enter image description here

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. Run the process you want to debug outside the debugger.
  2. In the other project, do Debug > Attach to Process > pick your process from the list.

2 Comments

Problem is that A_sol(one that generates C++ .dll) is not an executable solution. it is purely a library solution.
@newprint - if your library isn't used in any executables then there is no need for you to debug it, so that's a self-solving problem. If it is used in an executable, then you can run that executable and debug it from your library solution using Attach to Process just as I said.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.