2010-12-17 4 views
1

私はクライアントとサーバーの間でリモーティングを使用していますが、動作している間に私は理解できない動作を見ています。リモートプロキシが有効かどうかをテストしますか?

次のように私は私のサーバーを設定してい:

 BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); 
     serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;    
     BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); 

     IDictionary props = new Hashtable(); 
     props["name"] = "MarsLogServer.rem"; 
     props["port"] = Properties.Settings.Default.ListeningPort; 
     props["useIpAddress"] = false; 

     server = new LogServer(); 

     chan = new TcpChannel(props, clientProv, serverProv); 
     ChannelServices.RegisterChannel(chan, true);    
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(LogServer), "MarsLogServer.rem", WellKnownObjectMode.Singleton);    
を、次のように私のクライアントが接続されています

this.logServer = (ILogServer)Activator.GetObject(typeof(ILogServer), connectForm.Url); 
this.logServer.AttachClient(this, connectForm.SessionKey) 

何が起こっているが、私も、サーバーが実行されていませんが、クライアントが受け取るプロキシのAttachClient()への呼び出しは成功します。私はなぜそれがあるのか​​理解できません。誰かが私の上でひねりをしていない限り、提供されたURLにオブジェクトをホストしているプロセスはありません。なぜそれが例外をスローしないのですか?

理想的には、呼び出しが失敗したい、またはクライアントの処理を許可する前にプロキシが有効であることをテストする方法が必要です。今のところ、接続が成功したかどうかを知る方法はありません。

答えて

0

おそらくSystem.Runtime.Remoting.RemotingServices.IsTransparentProxy(クライアント)を使用して、TransparentProxy/RealProxyチェーンが設定されているかどうかをテストできますか?

-Oyin

+0

これは、trueを返します。 – Joe

関連する問題