如何在同一个远程URI上使用具有多层接口继承的多个WellKnownObjects?

时间:2019-01-02 00:46:07

标签: vb.net interface remoting

我正在尝试通过多层继承的接口在VB.NET中使用远程处理。

两个基本接口是ICallback和ICallTarget。它们都由IClass2Remote接口继承。

我在服务器上注册了多个WellKnownServiceType。在客户端上,我可以创建并使用IClass1Remote的代理。我也可以为IClass2Remote创建代理。但是,当尝试调用子项或函数或尝试向IClass2Remote接口中定义的Callback事件添加事件处理程序时,在运行时我从服务器收到一条错误消息:

试图在公开了“ Class1Remote”的对象上调用类型为“ Class2Remote”的声明的方法。

由于我在服务器上将两个接口类都注册为WellKnownServices,为什么会发生这种情况?以及我该如何解决?

   Public Interface ICallTarget
    <DispId(1)> Sub Start_CallTarget(Optional ByVal vData As Object = "")
    <DispId(2)> Sub Initialize_CallTarget(Optional ByVal vData As Object = "")
    <DispId(3)> Sub Terminate_CallTarget()
End Interface

Public Interface ICallBack
    <DispId(4)> Event Callback As CallbackEvent
    <DispId(5)> Sub Start_CallBack(ByVal sDocNum As String, ByVal sUserId As String, ByVal sComputerName As String)
    <DispId(6)> Property PleaseDestroy_CallBack() As Boolean

End Interface

Public Interface IClass2Remote
  Inherits ICallback, ICallTarget
  <DispId(7)> Sub Destroy()
End Interface



RemotingConfiguration.RegisterWellKnownServiceType(
              GetType(Class1Remote),
              "Class1Remote", WellKnownObjectMode.SingleCall)

RemotingConfiguration.RegisterWellKnownServiceType(
              GetType(Class2Remote),
              "Class2Remote", WellKnownObjectMode.SingleCall)

0 个答案:

没有答案