- PR -

IpcChannelを用いたプロセス間通信

1
投稿者投稿内容
焼きそば
会議室デビュー日: 2007/09/07
投稿数: 2
投稿日時: 2007-10-29 18:43
今まで、あるアセンブリ(.exe)内でIpcChannelを使ってプロセス間通信をしており、それはうまく動作していました。

今回、そのアセンブリをクラスライブラリ(.dll)とし、外部からリフレクションを用いて呼び出すよう変更したのですが、クライアントからのリモートオブジェクトへのアクセス時に例外が発生するようになってしまいました。

クラスライブラリやリフレクションを通しては利用できないとか、そのような類の制限があるのでしょうか。もしくは何か間違いがあれば、指摘していただければ幸いです。

以下はコードの主要部です。
<サーバ>
    IpcChannel channel = new IpcChannel("hoge");
    ChannelServices.RegisterChannel(channel, true);
    RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingObject), "hoga", WellKnownObjectMode.Singleton);
<クライアント>
  IpcChannel channel = new IpcChannel();
  ChannelServices.RegisterChannel(channel, true);
  WellKnownClientTypeEntry te = new WellKnownClientTypeEntry(typeof(RemotingObject), "ipc://hoge/hoga");
  RemotingConfiguration.RegisterWellKnownClientType(te);
  RemotingObject obj = (RemotingObject)Activator.GetObject(typeof(RemotingObject), "ipc://hoge/hoga);
  obj.SomeMethod(); // ←ここで例外

以下は例外の詳細です。
型:System.Runtime.Remoting.RemotingException
メッセージ:型 'Test.RemotingObject, <アセンブリ名>' を読み込めません。
スタックトレース:
Server stack trace:
場所 System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
場所 System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.GetServerTypeForUri(String URI)
場所 System.Runtime.Remoting.RemotingConfigHandler.GetServerTypeForUri(String URI)
場所 System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
場所 System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)

Exception rethrown at [0]:
場所 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
場所 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
場所 Test.RemotingObject.SomeMethod()
1

スキルアップ/キャリアアップ(JOB@IT)