[serializable] public class resume { private decimal resumeid, userid; private string body, title; public resume(decimal resumeid) { this.resumeid=resumeid; this.userid=1; this.body="this is the default body of the resume"; this.title="this is the default title"; }
public decimal resumeid { get { return resumeid; } set { this.resumeid=value; } } public decimal userid { get { return userid; } set { this.userid=value; } } public string body { get { return body; } set { this.body=value;} } public string title { get { return title; } set { this.title=value; } }
}//resume对象结束
}//dotnetremotetest名字空间结束
编译创建的工程,就会得到一个dll文件,并可以在其他的工程中使用它。
第二步:创建server对象
有几种方法可以创建server对象,最直观的方法是下面的方法:在visual studio.net中,依次点击“文件”->“新创建”->“工程”,选择创建一个“command line application”(命令行应用程序),并将它命名为resumesuperserver。
using system; using system.runtime; using system.runtime.remoting; using system.runtime.remoting.channels; using system.runtime.remoting.channels.tcp; using system.data.sqlclient; using dotnetremotetest; namespace resumeserverserver { public class resumesuperserver { public static void main(string[] args) { tcpserverchannel channel = new tcpserverchannel(9932); channelservices.registerchannel(channel); remotingconfiguration.registerwellknownservicetype(typeof(resumeloader), "resumeloader", wellknownobjectmode.singlecall); system.console.writeline("press any key"); system.console.readline(); } } }
resumeclient的全部代码如下所示: using system; using system.runtime.remoting; using system.runtime.remoting.channels; using system.runtime.remoting.channels.tcp; using dotnetremotetest;