码迷,mamicode.com
首页 > Web开发 > 详细

. Net Remoting体系结构(2) 远程对象 编程方式

时间:2015-12-07 12:12:24      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

1 创建服务器通道

  并在.Net Remotion运行时注册改通道

  注册一个知名对象

 

 1        TcpServerChannel channel = new TcpServerChannel(9000);
 2 
 3             ChannelServices.RegisterChannel(channel, false);
 4 
 5             WellKnownServiceTypeEntry remObj = new WellKnownServiceTypeEntry(
 6                 typeof(MyRemoteObject), "MyRemoteObject", WellKnownObjectMode.SingleCall);
 8 
 9             RemotingConfiguration.RegisterWellKnownServiceType(remObj);
10             
11             Console.ReadKey();

2 客户端端

  

 1             TcpClientChannel channel = new TcpClientChannel();
 2                 ChannelServices.RegisterChannel(channel,false);
 3                 //方式 1  
 4                 //WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry(typeof(MyRemoteObject),
 5                 //    "tcp://localhost:9000/MyRemoteObject");
 6                 //RemotingConfiguration.RegisterWellKnownClientType(entry);
 7                 //MyRemoteObject obj = new MyRemoteObject();
 8                 //方式 2
 9                 MyRemoteObject obj = (MyRemoteObject)Activator.GetObject(typeof(MyRemoteObject),
10                     "tcp://localhost:9000/MyRemoteObject");
11                
12                 Console.WriteLine(obj.Hello());        

 

. Net Remoting体系结构(2) 远程对象 编程方式

标签:

原文地址:http://www.cnblogs.com/shenshiting/p/5025422.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!