远程处理对象和远程连接

时间:2009-04-05 18:26:51

标签: c# remoting

我正在使用.NET远程处理一些简单的基于观察者的IPC。我遇到了两个问题:

  1. 如果我在远程对象上没有从客户端进行任何调用几分钟,则在尝试调用时会抛出错误,指定连接已被删除。我怎样才能保持活力?
  2. 我似乎无法通过TCP接受来自其他计算机的客户端。我正在使用如此配置的TcpChannel:

    BinaryServerFormatterSinkProvider serverProv = new 
        BinaryServerFormatterSinkProvider();
    serverProv.TypeFilterLevel = TypeFilterLevel.Full;
    BinaryClientFormatterSinkProvider clientProv = new 
        BinaryClientFormatterSinkProvider();
    IDictionary props = new Hashtable();
    props["port"] = port;
    TcpChannel channel = new TcpChannel( props, clientProv, serverProv );
    
    ChannelServices.RegisterChannel( channel, false );
    
    RemotingConfiguration.RegisterWellKnownServiceType( typeof( Controller ),
        "Controller", WellKnownObjectMode.Singleton );
    
  3. 当客户端应用尝试连接( m_Controller = (Controller)RemotingServices.Connect( typeof( Controller ), "tcp://" + ip + ":2594/Controller" ) )时,它总是超时。我不在防火墙后面,我的端口正确转发。我可以将此端口用于基于套接字的应用程序,但出于某种原因不能用于远程处理。请帮忙!

1 个答案:

答案 0 :(得分:0)

  1. 您是否已初始化Controller对象的生命周期?见http://www.diranieh.com/NETRemoting/InDepthRemoting.htm
  2. 请在此处查看我的回答:Remoting connection over TCP
相关问题