C# IPC信道跨进程通信

Server端:注册信道

1 /// <summary>
2         /// 注册IPC管道通讯
3         /// </summary>
4         public void IpcServer()
5         {
6             IpcServerChannel channel = new IpcServerChannel("ServerChannel");
7             ChannelServices.RegisterChannel(channel, false);
8             RemotingConfiguration.RegisterWellKnownServiceType(typeof(类型-class), "注册名称--对象名", WellKnownObjectMode.SingleCall);
9         }
View Code

Client端:连接获取信道

1 IpcClientChannel channel = new IpcClientChannel();
2                 ChannelServices.RegisterChannel(channel, false);
3 
4                 (类型-class) obj = (类型-class)Activator.GetObject(typeof(类型-class), "ipc://ServerChannel/注册信道名-对象名");
5 
6                 
View Code

 

posted on 2019-07-04 16:50  BennyHua  阅读(702)  评论(0编辑  收藏  举报

导航