static void Main(string[] args) { // change usingSingleton to false to use Marshal activation bool usingSingleton = false; HelloService myRem = null; TcpChannel channel = new TcpChannel(8086); ChannelServices.RegisterChannel(channel, true); if (usingSingleton) { RemotingConfiguration.RegisterWellKnownServiceType( typeof(HelloService), "HelloService", WellKnownObjectMode.Singleton); } else { myRem = new HelloService(); RemotingServices.Marshal(myRem, "HelloService"); } System.Console.WriteLine("<enter> to exit..."); System.Console.ReadLine(); }
static void Main() { TcpChannel channel = new TcpChannel(); ChannelServices.RegisterChannel(channel, true); HelloService obj = (HelloService)Activator.GetObject( typeof(HelloService), "tcp://localhost:8086/HelloService"); if (obj == null) { System.Console.WriteLine("Could not locate server"); } else { Console.WriteLine(obj.Hello()); } Console.ReadLine(); }