- - PR -
サーバー側でリモートオブジェクトを起動する方法について
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2003-10-10 15:02
はじめましてよろしくお願いします。
シングルトンサーバーオブジェクトを構成ファイルで登録しています。 登録後、クライアントから呼び出される前に初期化を行いたいので 以下のようなコードを書きました。 正常に動作しているようですが、サーバー側でのremoteObjの起動を クライアント側と同じ様に、構成ファイルで行うにはどの様にすれば 良いのでしょうか。 -------------------------------------------------------------------------- Server.cs -------------------------------------------------------------------------- private void MainForm_Load(object sender, System.EventArgs e) { RemotingConfiguration.Configure("Server.exe.config"); remoteObj = (RemoteObj)Activator.GetObject( typeof(RemoteObj), "tcp://localhost:8000/RemoteObj"); remoteObj.Init(); } -------------------------------------------------------------------------- Server.exe.config -------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="Singleton" type="Remote.RemoteObj, Remote" objectUri="RemoteObj" /> </service> <channels> <channel ref="tcp" port="8000" /> </channels> </application> </system.runtime.remoting> </configuration> -------------------------------------------------------------------------- Client.cs -------------------------------------------------------------------------- private void Form1_Load(object sender, System.EventArgs e) { RemotingConfiguration.Configure("Client.exe.config"); remoteObj = new RemoteObj(); remoteObj.Method(); } -------------------------------------------------------------------------- Client.exe.config -------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.runtime.remoting> <application> <client> <wellknown type="Remote.RemoteObj, Remote" url="tcp://localhost:8000/RemoteObj" /> </client> <channels> <channel ref="tcp" /> </channels> </application> </system.runtime.remoting> </configuration> -------------------------------------------------------------------------- |
1