0

I have been trying to debug a class library in a Solution A with a MVC project in Solution B. I run Solution B, set a breakpoint in Solution A, but the debugger never gets into Solution A.

I have already tried with this answer and this answer with no success.

How can I debug multiple Solutions in VS2012?

Thanks!

Community
  • 1
  • 1
gonzalomelov
  • 971
  • 1
  • 13
  • 30

2 Answers2

1

There are some ways to do this. But the easiest would be:

  1. Start Solution B
  2. Go to Solution A
  3. Go to Debug->Attach to Process...
  4. Choose the executable you're running (from Solution B, of course. You may have to check "Show processes from all users")

You need to link your Solution A to Solution B's debuggable version for this to work. Usually it's in the bin\Debug subdirectory of your project. In that case, your Breakpoint should be hit as soon as it's reached.

Another way would be:

  1. Open Solution A's properties.
  2. Go to Debug
  3. Under "Start Action" choose "Start external program:"
  4. Browse to Solution B's executable

Run Solution A.

Yet another way would be to insert into your class library the sentence Debugger.Break(); (which requires using System.Diagnostics;). Be careful to not release the debug version, though! As soon as it's reached, the System should throw up a dialog box asking if you'd like to debug the process. This process depends on the correct installation of all components as well...

DigCamara
  • 5,540
  • 4
  • 36
  • 47
  • I have done it however the breakpoint says that "The breakpoint will not be activated. No symbols were loaded for this document" – gonzalomelov May 03 '13 at 17:46
  • You need to link your executable to the debuggable version of your class library. So it really depends on how you're linking your Solution. – DigCamara May 03 '13 at 17:47
  • I have attached the iis process with the class library project but when I do that I have to detach the MVC project, which is very annoying. For the second solution, I don´t know which is the executable of an MVC project. Thanks!! – gonzalomelov May 03 '13 at 19:11
  • When you're attaching to the process, you have all kind of information about it already. One way to use that information is to look at the name and look at the directory tree of your project to find the process's file that has that name. Of course, in that case too the debugger will detach your second process from the first. It's like what Richard Walter says: create a new solution and add both projects to it so you can open them both in the same environment and debug them simultaneously. – DigCamara May 03 '13 at 19:16
0

Make a Solution C which contains both the class library from Solution A as well as the MVC project in Solution B. This will not require any changes or copies to the class library project or MVC project. In fact, you can keep those where they are, and simply add the existing projects to the new Solution C.

Richard Walters
  • 1,464
  • 8
  • 16