![](/img/trans.png)
[英].NET Remoting: how to access server application objects from remotable object?
[英]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
該消息表示大多數情況下客戶端找不到服務。 您可以使用以下步驟確定連接失敗的位置:
失敗的步驟表明失敗的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.