开发者

Starting new process

开发者 https://www.devze.com 2023-01-09 09:01 出处:网络
Under my solution I have 开发者_如何学Python2 projects Project A console application , Project B Winforms Window.

Under my solution I have 开发者_如何学Python2 projects Project A console application , Project B Winforms Window.

How I can From Project B to start new process with console application from Project A ?

I tried to making it via

    Process note = new Process();

    note.StartInfo.FileName   = "note.exe";
    note.StartInfo.Arguments = "123";

    note.Start();

But in that way i cant debug both processes from one vs instance . Any idea ?

Thanks


If the only reason that you want to start the two projects is that you want to be able to debug both of them you can also configure your solution to have multiple startup projects:

Solution -> Properties -> Set Startup Projects...

If you are going to start the other project as a separate project anyway, you could use

Debug -> Attach to Process

to attach to the newly started process. Then you will also be able to debug both processes in Visual Studio. Attaching the debugger can also be achieved programmatically. In project A you can add the following code to the Main method:

#if DEBUG
    System.Diagnostics.Debugger.Launch();
#endif

In the dialog that will then pop up you can select the already running instance of Visual Studio.


Another option is to start the Startup Project via F5 (or Debug > Start Debugging) and the second one by right-clicking the project and going Debug > Start New Instance.


You can start debugger in the application launched by the following statement

System.Diagnostics.Debugger.Break()

then you can choose the visual studio instance and start debugging.

0

精彩评论

暂无评论...
验证码 换一张
取 消