Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
两个C#exe之间的通信_C#_Wpf_Windows_Notifications_Ipc - Fatal编程技术网

两个C#exe之间的通信

两个C#exe之间的通信,c#,wpf,windows,notifications,ipc,C#,Wpf,Windows,Notifications,Ipc,我创建了一个C#WPF项目。我有两个exe的运行,都是由我创建的。一个exe有一个窗口,另一个没有 现在我想从exe到另一个进行通信。 我想从exe(无窗口)向另一个发送一条小消息 我真的对Windows C#中的IPC感到困惑,有人能建议我哪一个适合这个问题吗你的评论不应该太粗鲁 现在试试这个: 在客户端:使用以下几行创建客户端代理 // Create the proxy: EndpointAddress ep = new EndpointAddress("net.pipe://localh

我创建了一个C#WPF项目。我有两个exe的运行,都是由我创建的。一个exe有一个窗口,另一个没有

现在我想从exe到另一个进行通信。 我想从exe(无窗口)向另一个发送一条小消息


我真的对Windows C#中的IPC感到困惑,有人能建议我哪一个适合这个问题吗

你的评论不应该太粗鲁

现在试试这个:

在客户端:使用以下几行创建客户端代理

// Create  the proxy:
EndpointAddress ep = new EndpointAddress("net.pipe://localhost/SomeAddress/PipeEndpoint/");
IMyinterface instance = ChannelFactory<IMyinterface>.CreateChannel(new NetNamedPipeBinding(), ep);

// now use it:
instance.SendMessage();
服务器端的MyClass代码也是:

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyClass : IMyinterface
{

    public void SendMessage()
    {
        // do something here
    }

}
接口应位于单独的项目中,由客户端和服务器项目引用:

[ServiceContract]
interface IMyinterface
{
     [OperationContract]
    void SendMessage();
}
备注:当我说“客户”时,我指的是发送信息的人。服务器是接收消息的人。我认为在你的架构中是相反的,所以我想清楚我的术语


我希望它能对sthotakura有所帮助。您可以分享任何链接或示例吗。@user2431170您可以使用搜索引擎吗?@user2431170@JonathonReinhart。正如我已经说过的,我对在C#中实现IPC感到困惑。很抱歉,我不是像你这样能找到我所需要的一切的天才。仅供参考,我在谷歌搜索了将近1年后发布了这个问题hr@sthotakura. 非常感谢你。你分享的教程真的很有用。嗨,Rami,我使用了@sthotakura给出的相同示例。我想这看起来也一样。但我得到的是EndPointNotFoundException。这是我得到的消息,在网络上没有端点侦听。pipe://localhost/CommService/ 可以接受消息。(1)重新检查地址的正确性。(2) 这可能是时间问题,可能是您的客户端试图在服务器打开管道通道之前访问服务器?请检查此处的服务器代码和客户端代码
[ServiceContract]
interface IMyinterface
{
     [OperationContract]
    void SendMessage();
}