Reputation: 815
There is a program (a WPF app written in C#) that calls the other program ( commandline program written in C++) . They both are in the same solution. At some points, the caller gets some stuff done by using the other program by using the methodology provided in System.Diagnostics.Process
. I want to debug the both programs while testing this project. How to do that? is there some easy method like "attaching" which we do to libraries?
--EDIT--
Process A starts the process B. Then A waits until process B exits. Furthermore, B something very small like dir
on the command prompt which exits quickly.
Upvotes: 2
Views: 1970
Reputation: 815
Applied Solution:
In source of A , put a break-point below the place where command line arguments are generated for B (I put it at where proc.Start()
is called).
e.g.
Process otherProcess = new Process();
...
otherProcess.StartInfo.Arguments = "abc" + foo() + "," + bar();// what we need
...
otherProcess.Start(); // break-point is here
Run A in debug mode until the break-point is reached.
proc.StartInfo.Arguments
and copy the value for later usage.Upvotes: 2
Reputation: 7419
You could also write a small class that uses C++/Cli. To the outside, your class looks like any C# class, and can be used directly from C#. But inside the C++/Cli, you can freely call into C++. That way, you can remove the use of System.Diagnostics.Process and directly use the other program.
It's a bit of work up-front, but it allows you to directly step into the C++ code as you do with the C# code right now.
Upvotes: 0
Reputation: 16338
If I understand you correctly, just attach the debugger to the other process. From one instance of Visual Studio you can attach to more than just one process, but you cannot attach two debuggers to the same process. Make sure however, you attach the right debugger to each process, i.e. the native debugger to the C++ application and the managed debugger to the WPF application.
You can switched between the debugger processes from the Processes tool window (given they are both paused at breakpoints). The call stack and all the others are updated for the currently selected process there.
Upvotes: 1
Reputation: 1580
Run another instance of VS, open solution and try to connect to running process http://msdn.microsoft.com/en-us/library/vstudio/3s68z0b3.aspx
Upvotes: 0