天天看点

据lovecherry的一步一步学Remoting序列文章学习.net Remoting日记

  昨天,进行了.net Remoting的初步学习,虽然在之前就已经接触过这个概念,并且也了解一些,可是真正的.net Remoting程序还真从未曾真正的编写过。昨天看了lovecherry的一步一步学Remoting序列文章,总算是迈出了.net Remoting程序的第一步,所以将这个过程记录下来,以免以后遗忘掉了!

Code highlighting produced by Actipro CodeHighlighter (freeware) 

http://www.CodeHighlighter.com/-->using System; 

using System.Collections.Generic; 

using System.Linq; 

using System.Text; 

using RemoteObject; 

namespace RemoteClient 

    class MyClient 

    { 

        [STAThread] 

        static void Main(string[] args) 

        { 

            Console.WriteLine("开始接受服务端信息!"); 

            MyObject app = (MyObject)Activator.GetObject(typeof(RemoteObject.MyObject), System.Configuration.ConfigurationSettings.AppSettings["ServiceURL"]); 

            Console.WriteLine("第一次测试使用的函数"); 

            Console.WriteLine(app.Add(1, 2)); 

            Console.WriteLine("第二次测试使用的函数"); 

            Console.WriteLine(app.Count()); 

            Console.WriteLine("接受信息"); 

            Console.ReadLine(); 

        } 

    } 

  在这里可能会出现找不到MyObject的问题,这里的客户端和服务器端都需要引用RemoteObject类库才行!如下图所示:

<a target="_blank" href="http://blog.51cto.com/attachment/201203/224908761.jpg"></a>

本文转自程兴亮 51CTO博客,原文链接:http://blog.51cto.com/chengxingliang/821156

继续阅读