0

I have a VS 2008 Solution in VB.Net that has 2 projects - a Launcher and the App. The Launcher is what runs first, checks to make sure the App has all the latest files from the network, etc. and then launches the App. The Launcher allows the user to select their environment (Test, Production) then passes those values into the App.exe as command line arguments.

This works fine when running normally, but when trying to debug this, I'm trying to figure out how to start Debugging from the Launcher, then pass the selected Environment into the other project so it can read them as command line arguments. Thanks.

Shawn Steward
  • 6,773
  • 3
  • 24
  • 45
  • A little background info on why VS might not support automatically attaching to child processes: http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/07/20/can-the-vs-debugger-automatically-attach-to-any-child-spawned-by-a-process-being-debugged.aspx – Michael Burr Aug 03 '10 at 20:55

3 Answers3

2

One possible solution is to launch your executable without debugging and then attach the debugger to the second process that it launches.

http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx

Greg Sexton
  • 9,189
  • 7
  • 31
  • 37
  • You can attach to multiple processes, so you can actually debug them both if you like. – Kirk Woll Aug 03 '10 at 20:43
  • Yeah I know how to attach to processes this way, just doesn't help when the code I need to test runs immediately. Thanks for the suggestion, though. – Shawn Steward Aug 03 '10 at 21:38
  • Have you seen this post? http://stackoverflow.com/questions/361077/c-clr-remote-debugger-how-to-wait-until-attached If it's an option you could add code that waits for the debugger to be attached. – Greg Sexton Aug 03 '10 at 22:30
  • Thanks Greg, that seems like the best option for this. Waiting for the debugger to be attached works best, thanks! – Shawn Steward Aug 17 '10 at 15:40
0

I would think you would have to attach the debugger to the new process. If you want to do it manually you can use Tools => Attach to Process.

I think it is possible to attach a debugger programmatically, see below for some SO questions that address this:

Community
  • 1
  • 1
Nate
  • 2,462
  • 1
  • 20
  • 28
  • Thanks but not sure this is what I'm looking for. There must be a way to start up another project in the solution by creating a new object or something, right? – Shawn Steward Aug 03 '10 at 21:41
  • 1
    What if you started the debugger in the other process on load? That way it will run almost right away (in the main constructor or whatever) - System.Diagnostics.Debugger.Launch() --- http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.launch.aspx – Nate Aug 03 '10 at 23:32
0

If this is just a one-off kind of thing, the easiest option is probably to add a call to System.Diagnostics.Debugger.Break() in the child process' source code at an early point of its initialization. Verify what you want to verify, then remove the Break() call.

If you're just looking to verify a set of command line arguments, then I'd probably just log them using whatever facility you might be using for logging - you might even wish to keep that logging around. Nice and simple.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760