4

This question ...and the answer shows how to start another instance of a console app in Visual Studio when you already have one running.

I want to do the same BUT passing different args[]. For example, when debugging I want to start up 2 instances of MyConsoleApp.exe as follows...

"MyConsoleApp.exe Agent1"
"MyConsoleApp.exe Agent2"

Does anyone know how to do this?

(Using Visual Studio 2015 Pro)

Community
  • 1
  • 1
controlbox
  • 522
  • 4
  • 13
  • 1
    One option is to attach the debugger after starting your app from the command line with the desired args. This will require you to put in a `Sleep` or some such wait code at the start of your app, in order to give you enough time to attach the debugger. – Chris O Mar 31 '16 at 12:53
  • 1
    A nice way to quickly attach the debugger with a single button press is to put a `Debug.Fail()` somewhere early in the startup code. – bitbonk Jun 02 '18 at 11:38

1 Answers1

1

As far as I know you can't. What I'd do is open the solution in two VS instances and run it. Or else you can give it a go the following way too ( haven't tried this but ideally it should work)

  1. Create two console projects and add all your files as 'linked' files on both projects ( the same .cs files being used on both projects)

  2. Go to the solution and set one project as 'Start with Debugging' and other as start without debugging. ( or may be both as Start with Debugging- depending on your scenario) here is how you could do this.

Illuminati
  • 4,539
  • 2
  • 35
  • 55