如何传递参数并在两个C#windows应用程序之间接收它。 [英] how pass parameter and receive it between two C# windows application.

查看:376
本文介绍了如何传递参数并在两个C#windows应用程序之间接收它。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个解决方案中创建了两个项目A,B,项目A在特定时间将自动启动项目B,当项目B启动时,我无法传递值并从项目A接收到项目B.

I crate two project A,B in same solution ,Project A at specific time will launch project B automatically ,I can't pass value and receive it from Project A to Project B When Project B Launched.

我用  "的Process.Start(projectB.exepath)"启动项目B.请帮帮我。

I use  "Process.start(projectB.exepath)" to launch project B. Please help me.

推荐答案

" 当项目B启动时,我无法传递价值并从项目A收到项目B."

为什么不呢?
Process.Start
允许您指定参数传递给新进程。你可以传递你需要的任何东西(可以表示为字符串)。在你的进程B中,你可以通过Main方法获取参数(对于控制台应用程序)。

Why not? Process.Start allows you to specify the arguments to pass to the new process. You can pass whatever you need to (that can be expressed as strings). In your process B you can get the arguments via the Main method (for a console app).

//Process A
Process.Start("process.exe", "someArg");

//Process B
void Main ( string[] args )
{
   //Args contains "someArg"
}


如果您需要传递更复杂的数据,或者需要在Start之外的进程之间进行通信,那么您需要使用

IPC
机制。对于.NET,这往往是WCF,命名管道或套接字。

If you need to pass more complex data or you need to communicate between processes outside of Start then you'll need to use an IPC mechanism. For .NET this tends to be either WCF, named pipes or sockets.


这篇关于如何传递参数并在两个C#windows应用程序之间接收它。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆