当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .net remoting范例

ASP.NET
Internet Explorer 编程简述(二)在IE中编辑OLE嵌入文档
移动窗体
.NET 2.0获取数据库连接统计数据
VB.NET 拖动无边框的窗体
利用WH_CBT Hook将非模态对话框显示为模态对话框
Aspect#应用 - 权限验证
VB 从零开始编外挂(一)
【错误解决】Unable to find script library 'WebUIValidation.js'
VB 从零开始编外挂(四)
DTD指南(3)-DTD-Elements(元素)
知识库文章MDL9745154-File:Microsoft Visual Basic 运行时库
.net手机软件开发(六)OBEX应用:文件传输部分
在winform中使用WebBrowser控件时怎样去除IE的滚动条
WINZIP及WINRAR命令!!!!!
智能客户端相关Application Block结构功能分析(二)
如何在VB中操作EXCEL(一段代码,两个可以使用的过程)
在C#中用最简洁有效的代码执行存储过程并返回数据
.Net的Collection类的一些使用说明
ASP.NET实现数据图表c
用asp.net画饼图

ASP.NET 中的 .net remoting范例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 89 ::
收藏到网摘: n/a


1:创建一个工程文件,是SERVER端的。
using System;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Tcp;
namespace HelloServer{ /// /// Class1 的摘要说明。 /// class HS { /// /// 应用程序的主入口点。 /// [STAThread] static void Main(string[] args) { // // TODO: 在此处添加代码以启动应用程序 // try { TcpServerChannel channel =new TcpServerChannel(8086); ChannelServices.RegisterChannel(channel); Type t=typeof(RemoteHello.Hello); RemotingConfiguration.RegisterWellKnownServiceType(t,"hi",WellKnownObjectMode.SingleCall); Console.WriteLine("hit to exit"); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.ReadLine(); } } }}
2:创建一个工程文件是client端的:
using System;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Tcp;
namespace HelloClient{ /// /// Class1 的摘要说明。 /// class HC { /// /// 应用程序的主入口点。 /// [STAThread] static void Main(string[] args) { // // TODO: 在此处添加代码以启动应用程序 // try { TcpClientChannel tc=new TcpClientChannel(); ChannelServices.RegisterChannel(tc); RemoteHello.Hello obj = (RemoteHello.Hello)Activator.GetObject(typeof(RemoteHello.Hello),"tcp://10.10.10.111:8086/hi"); if(obj==null) { Console.WriteLine("FAILED!"); return; } for(int i=0;i<2;i++) { Console.WriteLine(obj.Greeting( )); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.ReadLine(); } } }}

3:在编译完以后,先运行server.exe文件,然后再运行client.exe文件,,,这样在MS-DOS下面,就可以看到,client掉用server。。。呵呵。。。完毕。。