[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;