簡體   English   中英

如何在遠程處理中從其他計算機訪問遠程對象

[英]How to access remote object from other computer in remoting

我有一個服務器對象

 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"

我在這里使用本地主機 ,因為我的服務器對象和客戶端是相同的。 因此,如果這兩個不同,則如何訪問服務器對象。 我嘗試使用另一台計算機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

該消息表示大多數情況下客戶端找不到服務。 您可以使用以下步驟確定連接失敗的位置:

  1. 檢查服務是否在遠程計算機上運行。
  2. 檢查端口號是否正確。
  3. 從客戶端Ping遠程計算機。
  4. 在服務的端口號上打開到遠程計算機的telnet會話。

失敗的步驟表明失敗的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM