How can you debug across projects in VB.Net if one launches the other?
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.
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
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:
- Is it possible to communicate with the Visual Studio debugger programmatically while debugging?
- How do I attach a process to the debugger in Visual Studio?
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.
精彩评论