IE 8のツールバーアドインであるIEブラウザヘルパーオブジェクトがあります。共通のインターフェイスを介してリモート処理を使用してこのBHO(リモートサーバー)に接続する別の.NET .EXEアプリケーション(リモートクライアント)があります。サーバーコンポーネントで使用されているのと同じコードを使用して.EXEアプリケーションとTEMPコンソールアプリケーション間の通信をテストすると、正常に通信し、リモートメソッドを実行します。
ただし、TCPチャネルのセキュリティを使用してBHOサーバーと通信しようとすると、ChannelServices.RegisterChannel(tcpClientChannel、true);がオンになります。、「FileNotFoundException」が発生します。ファイルまたはアセンブリ「xxxx」を読み込めませんでした。「xxxx」は、サーバーメソッドを含む一般的なインターフェイスアセンブリです。
TCPチャネルのセキュリティを使用してBHOサーバーと通信しようとするとOFFChannelServices.RegisterChannel(tcpClientChannel、false); 、「リモートオブジェクトへの接続が強制的に閉じられました」というエラーが表示されます。
単純なテストコンソールアプリで再テストすると、機能します。
問題はBHOインスタンス内でのリモーティングの動作にあると私は信じ始めています...BHO.NETインスタンスでリモーティングを使用した人はいますか?SPICIEライブラリを使用して.NETを使用してBHOを作成しています。
リモーティングインターフェイスオブジェクト名前空間のCOMMONインターフェイスアセンブリWWie.CommonClasses{classWWieRemote:MarshalByRefObject、WWieClassLibrary.WWieCommonClass.IGetHtmlElement {public string GetElementClicked(){return( "Returned from WWieRemote"); }
public void SetElementClicked(string str)
{
MessageBox.Show("SetElement " + str);
}
}
}
CLIENT APP static TcpChannel tcpClientChannel = new TcpChannel(); public static WWieClassLibrary.WWieCommonClass.IGetHtmlElement remoteObject; ChannelServices.RegisterChannel(tcpClientChannel、false); remoteObject =(WWieClassLibrary.WWieCommonClass.IGetHtmlElement)Activator.GetObject(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement)、 "tcp:// localhost:9002 / TestWWie");
リモートメソッド呼び出しによるテスト
remoteObject.SetElementClicked("from Client");
サーバーBHOTcpChanneltcpServerChannel = new TcpChannel(9002); ChannelServices.RegisterChannel(tcpServerChannel、true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(WWieClassLibrary.WWieCommonClass.IGetHtmlElement)、 "TestWWie"、WellKnownObjectMode.Singleton);