.NET FrameWoek2.0中,新添加一个IpcChannel,它是利用Windows的Ipc(进程间通讯)实现的一个Remoting的Channel,它的速度比Http或Tcp的Channel快很多,但它只能被用在本机不同应用程序域之间的通讯,所以,如果我们的客户端有可能与服务器端在同一个机器上运行时,可以通过注册IcpChannel来提高性能。下面是一个简单的IpcChannel的示例: Using directives#region Using directivesusing System;using System.Collections.Generic;using System.Text;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Ipc;#endregionnamespace TestIpcChannel{ class Program { static void Main(string[] args) { IpcChannel myChannel = new IpcChannel("test"); ChannelServices.RegisterChannel(myChannel); RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemObject), "RemObject.rem", WellKnownObjectMode.SingleCall); //服务注册结束,下面是客户端代码 RemObject obj = (RemObject)(Activator.GetObject(typeof(RemObject), "Ipc://Test/RemObject.rem")); obj.TestMethod(); Console.ReadLine(); } } public class RemObject : MarshalByRefObject { public void TestMethod() { Console.WriteLine("Hello IcpChannel!"); } }}为了便于大家读代码,该程序同时扮演服务器和客户端的角色,可以直接编译执行。 转载于:https://www.cnblogs.com/dahuaidan410/archive/2004/09/10/41726.html