3

リモーティング サーバー上のよく知られたサービスを、利用可能なすべてのチャネルではなく、特定のチャネルに登録できるかどうかを知りたいです。

私のコードは次のとおりです。

次のコードを使用して、リモーティング サーバーに 2 つの個別の tcpchannels を作成しました。

IDictionary rcProperties1 = new Hashtable();
rcProperties1["port"] = "1688";
rcProperties1["name"] = "tcp1";
TcpChannel tcp1 = new TcpChannel(rcProperties1, null, null);

IDictionary rcProperties2 = new Hashtable();
rcProperties2["port"] = "1689";
rcProperties2["name"] = "tcp2";
TcpChannel tcp2 = new TcpChannel(rcProperties2, null, null);

//--------------------------------------------------
// Register tcp channels
//--------------------------------------------------
ChannelServices.RegisterChannel(tcp1, false);
ChannelServices.RegisterChannel(tcp2, false);

次に、次のように2つのリモートオブジェクトをホストしました

Type rt = typeof(wxMessage);
RemotingConfiguration.RegisterWellKnownServiceType(
        rt, "Classes/wxMessage.rem", WellKnownObjectMode.Singleton);

rt = typeof(wxType);
RemotingConfiguration.RegisterWellKnownServiceType(
        rt, "Classes/wxType.rem", WellKnownObjectMode.Singleton);

クライアントでは、Activator.GetObject(...) を介してリモート オブジェクトを呼び出します。

string uri = "tcp://localhost:1688/";

IConcrete1 objMessageRemote = (IConcrete1)Activator.GetObject(
        typeMessageLocal, uri + "Classes/wxMessage.rem");

IConcrete2 objTypeRemote = (IConcrete2)Activator.GetObject(
        typeTypeLocal, uri + "Classes/wxType.rem");

つまり、uri ポートを 1688 に設定しても 1689 に設定しても、リモート オブジェクトを取得できます。

私がやりたいことは、サーバーが 1 つのチャネルで特定のオブジェクトをホストし、別のチャネルで別のオブジェクトをホストすることです。これはできますか?

4

0 に答える 0