这是一个客户端的调用,
同时你又想将它作为服务器方法供其它客户端调用,是吗?
可是你没有注明它的TCP通道吧

解决方案 »

  1.   

    有注册
    如下:
    TcpServerChannel channel = new TcpServerChannel(8086);
    ChannelServices.RegisterChannel(channel);
    RemotingConfiguration.RegisterWellKnownServiceType(typeof(Hello),"Hi",WellKnownObjectMode.SingleCall);
      

  2.   

    主程序:
    刚才改了一下,运行没有报错
    1. Hello类去掉通道注册的语句
    2. 将主程序中的TcpServerChannel改为TcpChannel如下:
    TcpChannel channel = new TcpChannel(8086);
    ChannelServices.RegisterChannel(channel);
    RemotingConfiguration.RegisterWellKnownServiceType(typeof(Hello),"Hi",WellKnownObjectMode.SingleCall);dll中Hello类如下:
    public class Hello: System.MarshalByRefObject 
    {public void CallAnoter()
    {
    (AnotherHello)Activator.GetObject(typeof(AnotherHello),"tcp://localhost:9999/test");
    if (obj == null)
    {
    Console.WriteLine("not create");
    return;
    }
    string str = obj.GetHelloString();
    Console.WriteLine(str);
    }
    }
      

  3.   

    只要建立一个通到就可以了
    不过不能是TcpServerChannel,要定义成TcpChannel