1

I have created a single command line application that handles different jobs per a command line argument. For instance, the "-w" starts a web project and "-c" runs a simple command line process.

Sometimes these two projects have to speak with each other. For instance, I start one instance with "-w" and an API web application launches. I start a second instance with "-c" and a command line application connects via API and processes some returned data.

I understand that I can debug multiple different projects at the same time, but is there a way to debug multiple instances of the SAME project in Visual Studio?

Trey Gourley
  • 391
  • 1
  • 7
  • 19
  • 1
    Start two instances of Visual studio with the same project. In each instance you can start a debug session for the same project (with a different parameter) – Johan Donne Nov 08 '18 at 20:38
  • This is for sure a valid option. Just curious if I am missing anything where this could be done in a single instance of Visual Studio. – Trey Gourley Nov 08 '18 at 20:52

2 Answers2

4

Yes:

  1. Debug your program normally to get the first instance
  2. Right click on your project in Solution Explorer and select Debug -> Start New Instance

You can also launch other programs in your solution as well.

MikeH
  • 4,242
  • 1
  • 17
  • 32
  • When I do this, it kills the first instance and the second instance never stops. Looks like there might be some conflict somewhere. – Trey Gourley Nov 09 '18 at 21:53
  • Additionally, if I could get them both to start up as you noted, how could I get the two instances to have different command line arguments? – Trey Gourley Nov 09 '18 at 21:54
  • Not sure why it would kill it. What version of VS are you using? Express? Do you have any code in your program looking for a second instance? This answer won't help with different arguments. I have an idea for that. New answer coming in a minute. – MikeH Nov 09 '18 at 22:01
  • I am running VS 2017 Pro. It wouldn't be surprising that something is a little off with my install. – Trey Gourley Nov 12 '18 at 13:29
1

If you want to pass different startup arguments to each instance, than you can do following:

For each instance you want to run:

  1. Add New Empty Project to the same Solution

  2. Under Project Properties -> Debugging specify

    • Command -> for example absolute path to the project .exe
    • Command Arguments
    • eventually other options like working dir , etc.
  3. Under Solution Properties choose Multiple startup projects and select projects you want to Debug at the same time

Now if you hit F5 you can debug all projects you want eventually some multiple instances with specific command line arguments for each one.

Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
StPiere
  • 4,113
  • 15
  • 24