我創建了一個Window Service,它在localhost中運行良好。但是,當我將它安裝到另一臺計算機上(使用我的帳戶)時,另一臺計算機上的客戶端返回「無法連接到遠程服務器」。如果客戶端在同一臺機器上運行,它就可以正常工作。我也嘗試在控制檯應用程序中託管相同的遠程對象,並且它可以在遠程計算機上正常工作。.NET Remoting:無法連接到Windows服務中的遠程對象(localhost除外)?
這是我服務的的OnStart()的代碼:
HttpChannel channel = new HttpChannel(8080);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService), "MyService", WellKnownObjectMode.Singleton);
下面是客戶端代碼:
ChannelServices.RegisterChannel(new HttpChannel(), false);
MyService myService = (MyService)Activator.GetObject(typeof(MyService), "http://xxx.xxx.xxx.xxx:8080/MyService");
我發現有人之前問這個問題在互聯網上,但無人接聽。任何人都有線索?
當您確定您正在使用的端口被阻止後,請重新啓用防火牆並創建允許該端口連接的例外。 – 2011-01-20 22:23:17