Beispiel #1
0
        static void Main(string[] args)
        {
            ChannelServices.RegisterChannel(new TcpClientChannel());
            ChannelServices.RegisterChannel(new HttpClientChannel());

            RemotingConfiguration.RegisterWellKnownClientType(
                typeof(Wrox.ProfessionalCSharp.Hello),
                "tcp://localhost:8086/Hi");

/*			Hello obj = (Hello)Activator.GetObject(
 *                              typeof(Wrox.ProfessionalCSharp.Hello),
 *                              "tcp://localhost:8086/Hi");
 */

            Hello obj = new Hello();

            //	Hello obj = (Hello)RemotingServices.Connect(typeof(Wrox.ProfessionalCSharp.Hello),
            //		"http://localhost:8085/Hi");

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }

            MySerialized ser = obj.GetMySerialized();

            if (!RemotingServices.IsTransparentProxy(ser))
            {
                Console.WriteLine("ser is not a transparent proxy");
            }
            ser.Foo();

            MyRemote rem = obj.GetMyRemote();

            if (RemotingServices.IsTransparentProxy(rem))
            {
                Console.WriteLine("rem is a transparent proxy");
            }
            rem.Foo();

/*
 *                      MySerialized ser1 = new MySerialized(1);
 *                      obj.InSerialized(ser1);
 *                      Console.WriteLine(ser1.A);
 *
 *                      MySerialized ser2 = new MySerialized(2);
 *                      obj.RefSerialized(ref ser2);
 *                      Console.WriteLine(ser2.A);
 *
 *                      MySerialized ser3;
 *                      obj.OutSerialized(out ser3);
 *                      Console.WriteLine(ser3.A);
 */
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press return after the server is started");
            Console.ReadLine();

            ChannelServices.RegisterChannel(new TcpClientChannel(), true);
            Hello obj = (Hello)Activator.GetObject(
                typeof(Hello), "tcp://localhost:8086/Hi");

            if (obj == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }
            Console.WriteLine(obj.Greeting("Helen Zhukova"));
            MySerialized ser = obj.GetMySerialized();

            if (!RemotingServices.IsTransparentProxy(ser))
            {
                Console.WriteLine("ser is not a transparent proxy");
            }
            ser.Foo();
        }