views:

56

answers:

3

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.

+2  A: 

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
You can attach to multiple processes, so you can actually debug them both if you like.
Kirk Woll
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
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
Thanks Greg, that seems like the best option for this. Waiting for the debugger to be attached works best, thanks!
Shawn Steward
A: 

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:

Nathan
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
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
Nathan
A: 

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