在这一节里我们建立了一个叫General的类库,在他里面主要是作为服务器端的一个函数:
他的完整代码如下:

.Net Remoting(3)我的第一个Remoting程序using System;
.Net Remoting(3)我的第一个Remoting程序
using System.Collections.Generic;
.Net Remoting(3)我的第一个Remoting程序
using System.Text;
.Net Remoting(3)我的第一个Remoting程序
.Net Remoting(3)我的第一个Remoting程序
namespace General
这里需要注意的是这个类必须继承MarshalByRefObject。
 然后我们新建一个叫Sever的控制台应用程序,添加多刚才General的引用,在Server控制台程序里建立一个类,完整代码如下:

 

.Net Remoting(3)我的第一个Remoting程序using System;
.Net Remoting(3)我的第一个Remoting程序
using System.Collections.Generic;
.Net Remoting(3)我的第一个Remoting程序
using System.Text;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels.Tcp;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels.Http;
.Net Remoting(3)我的第一个Remoting程序
using General;
.Net Remoting(3)我的第一个Remoting程序
namespace Server

之后建立一个WEB程序,添加General的引用,调用服务器的方法,完整代码如下:

.Net Remoting(3)我的第一个Remoting程序using System;
.Net Remoting(3)我的第一个Remoting程序
using System.Data;
.Net Remoting(3)我的第一个Remoting程序
using System.Configuration;
.Net Remoting(3)我的第一个Remoting程序
using System.Web;
.Net Remoting(3)我的第一个Remoting程序
using System.Web.Security;
.Net Remoting(3)我的第一个Remoting程序
using System.Web.UI;
.Net Remoting(3)我的第一个Remoting程序
using System.Web.UI.WebControls;
.Net Remoting(3)我的第一个Remoting程序
using System.Web.UI.WebControls.WebParts;
.Net Remoting(3)我的第一个Remoting程序
using System.Web.UI.HtmlControls;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels.Tcp;
.Net Remoting(3)我的第一个Remoting程序
using System.Runtime.Remoting.Channels.Http;
.Net Remoting(3)我的第一个Remoting程序
using System.IO;
.Net Remoting(3)我的第一个Remoting程序
using General;
.Net Remoting(3)我的第一个Remoting程序
.Net Remoting(3)我的第一个Remoting程序
.Net Remoting(3)我的第一个Remoting程序
public partial class _Default : System.Web.UI.Page 

之后我们首先运行Sever端,接着运行客户端。
在客户端输入测试,点击查看输入,结果如下:

.Net Remoting(3)我的第一个Remoting程序
完整代码下载

相关文章: