.Net中Remoting技術應用簡述
阿新 • • 發佈:2019-02-07
TcpClientChannel chnl = new TcpClientChannel(); ChannelServices.RegisterChannel(chnl, true);//註冊通訊通道 RemoteObjClass = //獲取遠端物件代理
(RemoteObjClass)Activator.GetObject(
Type.GetType("RemoteObject.RemoteObjClass,RemoteObject"),//遠端類所有在程式集路徑及名稱
"tcp://localhost:8888/SampleRemote");//呼叫時用到的URI
Console.WriteLine(.Multi(3,6));//呼叫遠端類中的方法
2),利用配置檔案實現:
配置檔案的內容如下:
<?xml version="1.0" encoding="utf-8" ?>
接著,還是需要我們在程式碼中編寫以下程式碼:
RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
RemoteObjClass RemonteObj = new RemoteObjClass ();
Console.WriteLine(RemonteObj.Multi(3,6));