예제 #1
0
        static void Main(string[] args)
        {
            /*创建通道*/
            HttpChannel channel = new HttpChannel();

            /*注册通道*/
            ChannelServices.RegisterChannel(channel, false);
            /*注册通道 的 远程处理类型*/
            RemotingConfiguration.RegisterWellKnownClientType(typeof(MessageMarshal.TestMessageMarshal),
                                                              "http://localhost:816/TestMessageMarshal");

            ///*创建消息实体*/
            MessageMarshal.TestMessageMarshal TestMessage = new MessageMarshal.TestMessageMarshal();

            while (true)
            {
                //sendmessage在client和dll中都没有指定怎么实现,是在server中指定了实现,但是client却可以调用。这就让是。net remote
                TestMessage.SendMessage("DateTime.Now:" + System.DateTime.Now.ToString());
                TestMessage.SendMsg("--DateTime.Now:" + System.DateTime.Now.ToString());

                //MessageMarshal.TestMessageMarshal.sendmsg("dasdf");//一般的程序,这样是可以调用委托的,但是这里提示null

                Console.WriteLine("send message...");
                Thread.Sleep(2000);
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            /*创建通道*/
            //IpcChannel channel = new IpcChannel();
            //HttpChannel channel_http = new HttpChannel();
            TcpChannel channel_tcp = new TcpChannel();

            /*注册通道*/
            ChannelServices.RegisterChannel(channel_tcp, false);
            /*注册通道 的 远程处理类型*/
            //RemotingConfiguration.RegisterWellKnownClientType(typeof(MessageMarshal.TestMessageMarshal), "http://localhost:8226/test");
            /*注册通道 的 远程处理类型*/
            //RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "http://localhost:8226/test");
            //RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "ipc://localhost:8226/test");
            RemotingConfiguration.RegisterActivatedClientType(typeof(MessageMarshal.TestMessageMarshal), "tcp://localhost:8226/test");
            /*创建消息实体*/
            MessageMarshal.TestMessageMarshal TestMessage = new MessageMarshal.TestMessageMarshal();

            while (true)
            {
                TestMessage.SendMessage("DateTime.Now:" + System.DateTime.Now.ToString());
                Console.WriteLine("send message...");
                Thread.Sleep(2000);
            }
        }