【问题标题】:How to access remote object from other computer in remoting如何在远程处理中从其他计算机访问远程对象
【发布时间】:2013-08-08 04:57:28
【问题描述】:

我有一个服务器对象

 TcpChannel tcp = new TcpChannel(1234);
        ChannelServices.RegisterChannel(tcp, false);
        string s = ConfigurationManager.AppSettings["remote"];
        RemotingConfiguration.RegisterWellKnownServiceType(typeof(TestRemoting.InitialClass1), "TestRemoting", WellKnownObjectMode.Singleton);
        Console.WriteLine("Server is running on 1234 channel...");
        Console.WriteLine("Press Enter to Stop");
        Console.ReadLine();

我正在以 mu 客户端形式访问该对象,例如

 InitialClass1 Icls = (InitialClass1)Activator.GetObject(typeof(InitialClass1), "tcp://localhost:1234//TestRemoting");

现在我将远程对象保存在另一台计算机中。如何从该计算机访问我的服务器对象。如果我从我的(本地)计算机访问服务器对象,我将使用

"tcp://localhost:1234//TestRemoting"

我在这里使用 localhost,因为我的服务器对象和我的客户端是相同的。因此,如果这两者不同,我该如何访问服务器对象。 我尝试使用我的另一台计算机 IP 作为

tcp://200.100.0.52:1234//TestRemoting

那个时候我得到一个例外

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 200.100.0.52:1234

【问题讨论】:

    标签: c# winforms remoting


    【解决方案1】:

    该消息意味着客户端大部分时间都找不到服务。您可以使用以下步骤来确定连接失败的位置:

    1. 检查服务是否在远程机器上运行。
    2. 检查端口号是否正确。
    3. 从客户端 ping 远程计算机。
    4. 在服务端口号上打开到远程计算机的 telnet 会话。

    失败的步骤说明了失败的原因。

    【讨论】:

    • 知道了。我已将我的 tcp://200.100.0.52:1234//TestRemoting IP 更改为其他计算机名称。
    猜你喜欢
    • 2014-05-21
    • 2018-01-30
    • 1970-01-01
    • 2010-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    相关资源
    最近更新 更多