Esempio n. 1
0
File: client.cs Progetto: mono/gert
	static int Main (string [] args)
	{
		TcpChannel chan = new TcpChannel ();
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif

		TestService sv = (TestService) RemotingServices.Connect (typeof (TestService),
									 "tcp://localhost:8089/test");

		try {
			for (int i = 0; i < 100; i++) {
				TestEnumBI64 arg = TestEnumBI64.AL;
				TestEnumBI64 result = sv.Echo (arg);

				if (arg != result)
					return 1;
				if ((long) arg != (long) result)
					return 2;
				if (!arg.Equals (result))
					return 3;
			}
		} finally {
			ChannelServices.UnregisterChannel (chan);
		}

		return 0;
	}
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start..");
            Console.ReadKey();

            Server = new TcpChannel();

            Timer = new Timer(OnTick, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(50));

            Server.EventInform += (s, e) => Console.WriteLine(e.Data.Message);
            Server.GetInform += (s, e) => Console.WriteLine("Got: {0}", e.Data.Value);
            Server.CheckInform += (s, e) => Console.WriteLine(e.Data.Success);

            Server.GetAllInform += (s, e) =>
            {
                Console.WriteLine("Test: Data Coherence Test...");
                foreach (var entity in e.Data.Table)
                {
                    // Check the entity
                    Server.Check(entity.Key, entity.Value);
                }
            };

            Server.Connected += (s, e) =>
            {
                Server.GetAll();
            };
            Server.Connect("127.0.0.1", 8002);

            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
        }
Esempio n. 3
0
File: test.cs Progetto: mono/gert
	static void Register (string name, string port, IServerChannelSinkProvider provider)
	{
		Hashtable props = new Hashtable ();
		props ["name"] = name;
		props ["port"] = port;
		TcpChannel c = new TcpChannel (props, null, provider);
		ChannelServices.RegisterChannel (c, false);
	}
Esempio n. 4
0
File: server.cs Progetto: mono/gert
	static void Main ()
	{
		TcpChannel tcpChannel = new TcpChannel (1238);
		ChannelServices.RegisterChannel (tcpChannel);

		RemotingConfiguration.RegisterWellKnownServiceType (typeof (MyRemoteObject), "MyRemoteObject.soap", WellKnownObjectMode.Singleton);
		Console.ReadLine ();
	}
Esempio n. 5
0
    public static void Main(string[] args)
    {
        var channel = new TcpChannel(new Hashtable() { { "port", 8080 } }, null, new JsonServerFormatterSinkProvider());
        //var channel = new TcpChannel(new Hashtable() { { "port", 8080 } }, null, null);
        ChannelServices.RegisterChannel(channel, false);
        RemotingServices.Marshal(new ServiceClass(), "remote");

        Console.WriteLine("Remoting server running at tcp://localhost:8080/remote");
        Console.ReadKey();
        //System.Threading.Thread.Sleep(10000000);
    }
Esempio n. 6
0
File: test.cs Progetto: mono/gert
	static int Main ()
	{
		TcpChannel channel = new TcpChannel (1234);
		if (channel.ChannelName != "tcp")
			return 1;
#if NET_2_0
		if (channel.IsSecured)
			return 2;
#endif
		return 0;
	}
Esempio n. 7
0
File: server.cs Progetto: mono/gert
	static void Main( string[] args )
	{
		TcpChannel chan = new TcpChannel (8085);
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif
		RemotingConfiguration.RegisterWellKnownServiceType (typeof (Common.HelloClass),
			"SayHello", WellKnownObjectMode.Singleton);
		Console.ReadLine();
	}
Esempio n. 8
0
File: server.cs Progetto: mono/gert
	static void Main (string [] args)
	{
		TestServiceImpl impl = new TestServiceImpl ();
		RemotingServices.Marshal (impl, "test");
		TcpChannel chan = new TcpChannel (8089);
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif
		Console.ReadLine ();
		ChannelServices.UnregisterChannel (chan);
	}
Esempio n. 9
0
    public static void Main(string[] args)
    {
        // Generate unique system ID
        ManagementClass mc = new ManagementClass("Win32_Processor");
        ManagementObjectCollection moc = mc.GetInstances();
        foreach (ManagementObject mo in moc)
        {
            uuid = mo.Properties["processorID"].Value.ToString();
            Console.WriteLine("Unique ID for agent: " + uuid);
            break;
        }

        // Create the channel.
        TcpChannel clientChannel = new TcpChannel();

        // Register the channel.
        ChannelServices.RegisterChannel(clientChannel, false);

        //// Register as client for remote object.
        //WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(
        //    typeof(IVPrefServiceProvider), "tcp://localhost:6001/vPreServer.rem");
        //RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        //// Create a message sink.
        //string objectUri;
        //System.Runtime.Remoting.Messaging.IMessageSink messageSink =
        //    clientChannel.CreateMessageSink(
        //        "tcp://localhost:6001/vPreServer.rem", null,
        //        out objectUri);
        //Console.WriteLine("The URI of the message sink is {0}.",
        //    objectUri);
        //if (messageSink != null)
        //{
        //    Console.WriteLine("The type of the message sink is {0}.",
        //        messageSink.GetType().ToString());
        //}

        // Create an instance of the remote object.
        IVPrefServiceProvider service = (IVPrefServiceProvider)RemotingServices.Connect(typeof(IVPrefServiceProvider), "tcp://localhost:6001/vPreServer.soap");

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("count is " + service.returnInterCount());

        while (true)
        {
            System.Threading.Thread.Sleep(2000);
            Dictionary<String, String> dict = IOStatManager.getInstance.getDiskInformation();
            service.reportIO(uuid, dict);
        }
    }
Esempio n. 10
0
File: server.cs Progetto: mono/gert
	static void Main (string [] args)
	{
		TcpChannel chan = new TcpChannel (8085);
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif

		RemotingConfiguration.RegisterWellKnownServiceType (
			typeof (RemoteObject),
			"RemotingServer",
			WellKnownObjectMode.SingleCall);
		Console.ReadLine ();
	}
Esempio n. 11
0
File: client.cs Progetto: mono/gert
	static int Main (string [] args)
	{
		TcpChannel chan = new TcpChannel ();
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif
		RemoteObject remObject = (RemoteObject) Activator.GetObject (
			typeof (RemoteObject),
			"tcp://localhost:8085/RemotingServer");
		Assert.AreEqual ("Reply: You there?", remObject.ReplyMessage ("You there?"), "#1");
		Assert.AreEqual ("Hello, World!", remObject.serverString, "#2");
		Assert.AreEqual (new DateTime (1973, 8, 13), remObject.serverTimestamp, "#3");
		return 0;
	}
Esempio n. 12
0
File: server.cs Progetto: mono/gert
	static void Main ()
	{
		TcpChannel channel = new TcpChannel (8082);
#if NET_2_0
		ChannelServices.RegisterChannel (channel, false);
#else
		ChannelServices.RegisterChannel (channel);
#endif

		Service service = new Service ();
		ObjRef obj = RemotingServices.Marshal (service, "TcpService");

		RemotingServices.Unmarshal (obj);

		Console.ReadLine ();

		RemotingServices.Disconnect (service);
	}
Esempio n. 13
0
	public static int Main (string[] args) {
		channel = new TcpChannel (0);
		ChannelServices.RegisterChannel (channel);

		//RemotingConfiguration.RegisterWellKnownServiceType (typeof (MBInstallClient),
		//						    "MBuild.InstallerService", 
		//						    WellKnownObjectMode.Singleton);

		notify = (IInstallerServiceNotify) Activator.GetObject (typeof (IInstallerServiceNotify),
									"tcp://localhost:9414/MBuild.InstallerServiceNotify");

		singleton = new MBInstallClient ();
		notify.NotifyInstallerService (singleton);

		while (keep_going)
			System.Threading.Thread.Sleep (100);

		return 0;
	}
Esempio n. 14
0
File: client.cs Progetto: mono/gert
	static int Main ()
	{
		TcpChannel chan = new TcpChannel ();
#if NET_2_0
		ChannelServices.RegisterChannel (chan, false);
#else
		ChannelServices.RegisterChannel (chan);
#endif

		Common.ISayHello helloObj = Activator.GetObject (typeof (Common.ISayHello),
			"tcp://localhost:8085/SayHello") as Common.ISayHello;

		if (helloObj == null)
			Console.WriteLine ("Could not locate server");

		if (helloObj.SayHello () != "Hello")
			return 1;
		return 0;
	}
Esempio n. 15
0
File: client.cs Progetto: mono/gert
	static void Main ()
	{
		TcpChannel chnl = new TcpChannel (0);
		ChannelServices.RegisterChannel (chnl);
		ITest obj = (ITest) Activator.GetObject (typeof (ITest),
			"tcp://localhost:1238/MyRemoteObject.soap");

		IWhatever whatever;

		whatever = obj.Do (1);
		Assert.AreEqual ("one", whatever.Execute (), "#1");
		whatever = obj.Do (2);
		Assert.AreEqual ("two", whatever.Execute (), "#2");
#if MONO
		whatever = new WhateverThree ();
		Assert.AreEqual ("three", obj.Execute (whatever), "#3");
#endif
		whatever = new WhateverFour ();
		Assert.AreEqual ("four", obj.Execute (whatever), "#4");
	}
Esempio n. 16
0
	static void Main ()
	{
		BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider ();
		provider.TypeFilterLevel = TypeFilterLevel.Full;

		IDictionary props = new Hashtable ();
		props ["port"] = 5000;
		props ["name"] = "originalTcpChannel";

		TcpChannel channel = new TcpChannel (props, null, provider);
#if NET_2_0
		ChannelServices.RegisterChannel(channel, false);
#else
		ChannelServices.RegisterChannel (channel);
#endif

		RemotingServices.Marshal (new MyTest (), "Test");

		Console.ReadLine ();
	}
Esempio n. 17
0
        static void Main()
        {
            DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.v20_1;
#if EASYTEST
            DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register();
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            EditModelPermission.AlwaysGranted = System.Diagnostics.Debugger.IsAttached;
            SecuritySystemExampleWindowsFormsApplication winApplication =
                new SecuritySystemExampleWindowsFormsApplication();
            string connectionString = "tcp://localhost:1425/DataServer";
            winApplication.ConnectionString = connectionString;
            try {
                Hashtable t = new Hashtable();
                t.Add("secure", true);
                t.Add("tokenImpersonationLevel", "impersonation");
                TcpChannel channel = new TcpChannel(t, null, null);
                ChannelServices.RegisterChannel(channel, true);
                IDataServer clientDataServer = (IDataServer)Activator.GetObject(
                    typeof(RemoteSecuredDataServer), connectionString);
                ServerSecurityClient securityClient =
                    new ServerSecurityClient(clientDataServer, new ClientInfoFactory());
                securityClient.IsSupportChangePassword = true;
                winApplication.ApplicationName         = "SecuritySystemExample";
                winApplication.Security = securityClient;
                winApplication.CreateCustomObjectSpaceProvider +=
                    delegate(object sender, CreateCustomObjectSpaceProviderEventArgs e) {
                    e.ObjectSpaceProvider =
                        new DataServerObjectSpaceProvider(clientDataServer, securityClient);
                };
                winApplication.Setup();
                winApplication.Start();
            }
            catch (Exception e) {
                winApplication.HandleException(e);
            }
        }
Esempio n. 18
0
        public ServerApi(string id, string url, int minDelay, int maxDelay, List <String> urls)
        {
            int        port    = DU.ExtractPortFromUrl(url);
            TcpChannel Channel = new TcpChannel(DU.ExtractPortFromUrl(url));

            ChannelServices.RegisterChannel(Channel, false);

            Dictionary <string, Pingable> TupleSpaces = new Dictionary <string, Pingable>();
            string selfURL = "";

            foreach (string serverUrl in urls)
            {
                if (port != DU.ExtractPortFromUrl(serverUrl))
                {
                    Console.WriteLine(serverUrl);
                    TupleSpaces.Add(serverUrl, (TupleSpace)Activator.GetObject(typeof(TupleSpace), serverUrl));
                }
                else
                {
                    selfURL = serverUrl;
                }
            }

            TupleSpace tupleSpace = new TupleSpace(selfURL, minDelay, maxDelay, TupleSpaces);

            RemotingServices.Marshal(tupleSpace, DU.ExtractObjectNameFromUrl(url));
            tupleSpace.Stopped = true;
            List <TupleSpace> tupleSpaces = new List <TupleSpace>();

            foreach (var entry in TupleSpaces)
            {
                tupleSpaces.Add((TupleSpace)entry.Value);
            }
            tupleSpace.Update();
            tupleSpace.Stopped = false;
            Console.WriteLine("Enter to exit");
            Console.ReadLine();
        }
Esempio n. 19
0
    public static void Main()
    {
// <Snippet2>
// <Snippet3>

        TcpChannel myChannel = new TcpChannel(8085);

        ChannelServices.RegisterChannel(myChannel);

        MyServiceClass myService = new MyServiceClass();

        // After the channel is registered, register the object
        // with remoting infrastructure by calling Marshal method.
        ObjRef myObjRef = RemotingServices.Marshal(myService, "TcpService");

        // Get the information contributed by active channel.
        IChannelInfo      myChannelInfo = myObjRef.ChannelInfo;
        IChannelDataStore myIChannelData;

        foreach (object myChannelData in myChannelInfo.ChannelData)
        {
            if (myChannelData is IChannelDataStore)
            {
                myIChannelData = (IChannelDataStore)myChannelData;
                foreach (string myUri in myIChannelData.ChannelUris)
                {
                    Console.WriteLine("Channel Uris are -> " + myUri);
                }
                // Add custom data.
                string myKey = "Key1";
                myIChannelData[myKey] = "My Data";
                Console.WriteLine(myIChannelData[myKey].ToString());
            }
        }

// </Snippet3>
// </Snippet2>
    }
Esempio n. 20
0
    public static void Main(string[] args)
    {
        // Create the channel.
        TcpChannel clientChannel = new TcpChannel();

        // Register the channel.
        ChannelServices.RegisterChannel(clientChannel);

        // Register as client for remote object.
        WellKnownClientTypeEntry remoteType = new WellKnownClientTypeEntry(
            typeof(RemoteObject),
            "tcp://localhost:9090/RemoteObject.rem");

        RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            clientChannel.CreateMessageSink(
                "tcp://localhost:9090/RemoteObject.rem", null,
                out objectUri);
        Console.WriteLine("The URI of the message sink is {0}.",
                          objectUri);
        if (messageSink != null)
        {
            Console.WriteLine("The type of the message sink is {0}.",
                              messageSink.GetType().ToString());
        }

        // Create an instance of the remote object.
        RemoteObject service = new RemoteObject();

        // Invoke a method on the remote object.
        Console.WriteLine("The client is invoking the remote object.");
        Console.WriteLine("The remote object has been called {0} times.",
                          service.GetCount());
    }
Esempio n. 21
0
        }     //GetOptions()

        /// <summary>
        /// Runs this program as a server.
        /// </summary>
        public static void Run(ChannelKind ChanKind, WellKnownObjectMode ObjMode, Type ObjType)
        {
            TcpChannel  tcpchan;
            HttpChannel httpchan;

            Console.WriteLine("\nStarting server in WellKnownObjectMode {0}\n", ObjMode.ToString());

            switch (ChanKind)
            {
            case ChannelKind.Http:
                httpchan = new HttpChannel(Server.HTTPPORT);
                ChannelServices.RegisterChannel(httpchan);
                break;

            case ChannelKind.TCP:
                tcpchan = new TcpChannel(Server.TCPPORT);
                ChannelServices.RegisterChannel(tcpchan);
                break;

            case ChannelKind.Both:
                httpchan = new HttpChannel(Server.HTTPPORT);
                ChannelServices.RegisterChannel(httpchan);
                tcpchan = new TcpChannel(Server.TCPPORT);
                ChannelServices.RegisterChannel(tcpchan);
                break;

            default:
                throw new System.InvalidOperationException("Unexpected Channel kind in Server.Run()");
            }//switch

            RemotingConfiguration.RegisterWellKnownServiceType(ObjType,
                                                               "SayHello",
                                                               ObjMode);

            System.Console.WriteLine("Hit <enter> to exit...");
            System.Console.ReadLine();
            return;
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            SistemaConciliacion.PublicarServicioConciliacion();
            TcpChannel channel = new TcpChannel(5000);

            ChannelServices.RegisterChannel(channel, false);
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(OperacionConciliacion), "OperacionConciliacion",
                WellKnownObjectMode.Singleton);
            Console.WriteLine("Remote server is running");
            //Console.ReadLine();

            var connected = true;

            while (connected)
            {
                ImprimirMenu();
                var opcion = Console.ReadLine();
                if (opcion == "1")
                {
                    var estadisticasRegistro     = SistemaConciliacion.listaRegistroActividad;
                    var estadisticasConciliacion = SistemaConciliacion.listaEventos;
                    Console.WriteLine("Estadisticas del Servidor de Registro");
                    SistemaConciliacion.generarEstadisticas(estadisticasRegistro);
                    Console.WriteLine("Estadisticas del Servidor de Conciliacion");
                    SistemaConciliacion.generarEstadisticas(estadisticasConciliacion);
                }
                else if (opcion == "2")
                {
                    connected = false;
                }
                else
                {
                    Console.WriteLine("ERROR. Ingrese un comando valido");
                }
            }
            ChannelServices.UnregisterChannel(channel);
        }
Esempio n. 23
0
        private void stopServices()
        {
            running = false;
            try
            {
                // stop remoting
                try
                {
                    ChannelServices.UnregisterChannel(channel);
                    channel.StopListening(null);
                    channel = null;
                }
                catch (Exception) {}

                //DateTime StopTime = DateTime.Now;
                try
                {
                    serviceThreadManager.StopManager();
                }
                catch (Exception exc)
                {
                    EPSEventLog.WriteEntry("Error stopping threads" + Environment.NewLine + exc.ToString(), EventLogEntryType.Error);
                }

                // Wait until all processes have stopped to proceed
                do
                {
                    Thread.Sleep(100);
                } while (serviceThreadManager.sRunningProcesses + serviceThreadManager.lRunningProcesses > 0);


                EPSEventLog.WriteEntry("Services stopped.", EventLogEntryType.Information);
            }
            catch (Exception exc)
            {
                EPSEventLog.WriteEntry("Error stopping services" + Environment.NewLine + exc.ToString(), EventLogEntryType.Error);
            }
        }
Esempio n. 24
0
        public static void Initialize()
        {
            try
            {
                _RemoteService = new UOBlackBoxService.UOBlackBoxService();

                _Channel = new TcpChannel(Port);

                ChannelServices.RegisterChannel(_Channel, false);

                RemotingConfiguration.RegisterWellKnownServiceType(typeof(UOBlackBoxService.UOBlackBoxService), "RegisterCommand", WellKnownObjectMode.Singleton);

                BBServerMessage.WriteConsoleColored(ConsoleColor.DarkGray, "UO Black Box ~ Remote Service : Started @ " + DateTime.Now);

                // Show the URIs associated with the channel.
                ChannelDataStore data = (ChannelDataStore)_Channel.ChannelData;
                foreach (string uri in data.ChannelUris)
                {
                    if (uri.Contains(":"))
                    {
                        string[] GetConnection = uri.Substring(6).Split(':');

                        if (GetConnection.Length > 0)
                        {
                            BBServerMessage.WriteConsoleColored(ConsoleColor.Cyan, "UO Black Box ~ Remote Service : Listening @ [IP = " + GetConnection[0] + "] : [PORT = " + GetConnection[1] + "]");
                        }
                    }
                }

                UOBlackBoxService.UOBlackBoxService.CommandCall += CallServer;

                ServerIsRunning = true;
            }
            catch (Exception ex)
            {
                BBServerMessage.LogPacketCMD("ERROR", "UO Black Box Service : Failed : " + ex.Message, true);
            }
        }
Esempio n. 25
0
        static void Main(string[] args)
        {
            TcpChannel channel = new TcpChannel();

            ChannelServices.RegisterChannel(channel, false);

            ClientApp clientApp = new ClientApp();


            PadiDstm.Init();
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //Console.WriteLine("About to recover");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");


            //clientApp.PadiDstm.Status();


            //clientApp.PadiDstm.Recover("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Freeze("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Freeze("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //clientApp.PadiDstm.Fail("tcp://localhost:8089/Server");
            //Console.WriteLine("After fail");


            //Console.ReadLine();
            //clientApp.transaction1();
            //clientApp.transaction2();

            Console.ReadLine();
            PadiDstm.Status();
            Console.ReadLine();
        }
Esempio n. 26
0
        private void selfPrepare(int min_delay, int max_delay)
        {
            serverRemoteObjects = new Dictionary <string, IServerService>();
            matchIndexMap       = new Dictionary <string, int>();

            channel = new TcpChannel(_port);
            Console.WriteLine(_port.ToString());
            ChannelServices.RegisterChannel(channel, false);

            myRemoteObject = new ServerService(this, min_delay, max_delay);
            RemotingServices.Marshal(myRemoteObject, _name, typeof(ServerService)); //TODO remote object name
            fd = new FailureDetector();
            Console.WriteLine("Hello! I'm a Server at port " + _port);

            foreach (string url in ConfigurationManager.AppSettings.AllKeys)
            {
                string[] urlSplit = url.Split(new Char[] { '/', ':' }, StringSplitOptions.RemoveEmptyEntries);
                int      portOut;
                Int32.TryParse(urlSplit[2], out portOut);
                //not to connect to himself
                if (portOut != _port)
                {
                    serverRemoteObjects.Add(url, (ServerService)Activator.GetObject(typeof(ServerService), url));
                    matchIndexMap.Add(url, 0);
                }
            }
            _numServers = serverRemoteObjects.Count;

            List <string> view = fd.getView();

            while (view == null || view.Count == 0)
            {
                Thread.Sleep(100);
                view = fd.getView();
            }
            _state = new FollowerState(this, 0);;
            Console.WriteLine("Finished constructing server " + _port + " with thread " + Thread.CurrentThread.ManagedThreadId);
        }
Esempio n. 27
0
        public ScriptLoader()
        {
            InitializeComponent();

            url = "";

            // Get the IP's host
            IPHostEntry host;

            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    url = ip.ToString();
                }
            }

            CreateClient(url);

            String remoteObjectName = "PM";

            // Prepend the protocol and append the port
            int tcpPort = NextFreeTcpPort(20001, 29999);

            url = "tcp://" + url + ":" + tcpPort + "/" + remoteObjectName;

            System.Environment.SetEnvironmentVariable(PUPPET_MASTER_PORT, tcpPort.ToString(), EnvironmentVariableTarget.Process);

            // Register the Puppet Master Service
            TcpChannel channel = new TcpChannel(tcpPort);

            ChannelServices.RegisterChannel(channel, true);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(PuppetMasterImplementation), remoteObjectName, WellKnownObjectMode.Singleton);

            // Console message
            Console.WriteLine("Created PuppetMaster at " + url + ".");
        }
Esempio n. 28
0
        public void ExecuteMessage()
        {
            TcpChannel chn = null;

            try
            {
                chn = new TcpChannel(1235);
                ChannelServices.RegisterChannel(chn);

                MarshalObject objMarshal = NewMarshalObject();
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);

                // use a proxy to catch the Message
                MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalObject)Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));

                MarshalObject objRem = (MarshalObject)proxy.GetTransparentProxy();

                objRem.Method1();

                // Tests RemotingServices.GetMethodBaseFromMethodMessage()
                AssertEquals("#A09", "Method1", proxy.MthBase.Name);
                Assert.IsTrue(!proxy.IsMethodOverloaded, "#A09.1");

                objRem.Method2();
                Assert.IsTrue(proxy.IsMethodOverloaded, "#A09.2");

                // Tests RemotingServices.ExecuteMessage();
                // If ExecuteMessage does it job well, Method1 should be called 2 times
                Assert.AreEqual(2, MarshalObject.Called, "#A10");
            }
            finally
            {
                if (chn != null)
                {
                    ChannelServices.UnregisterChannel(chn);
                }
            }
        }
Esempio n. 29
0
    public static void Main()
    {
        int        option     = 0;
        TcpChannel tcpChannel = new TcpChannel();

        ChannelServices.RegisterChannel(tcpChannel);
        Type             requiredType = typeof(CounterInterface);
        CounterInterface c            =
            (CounterInterface)Activator.GetObject(requiredType,
                                                  "tcp://localhost:9998/MyCounter");

        while (option != 5)
        {
            Console.WriteLine("Choose Option\n-------------\n1. Increment\n2. Decrement\n3. Read value\n4. Reset\n5. Quit");
            option = Convert.ToInt32(Console.ReadLine());
            if (option == 1)
            {
                c.increment();
            }
            else if (option == 2)
            {
                c.decrement();
            }
            else if (option == 3)
            {
                int val = c.read_value();
                Console.WriteLine("Value = {0}", val);
            }
            else if (option == 4)
            {
                c.reset();
            }
            else if (option != 5)
            {
                Console.WriteLine("Invalid Option");
            }
        }
    }
Esempio n. 30
0
        public static int Main(string [] args)
        {
            HttpChannel chan1 = new HttpChannel();

            ChannelServices.RegisterChannel(chan1);
            AServer aServer = (AServer)Activator.GetObject(
                typeof(Lab13.AServer),
                "http://localhost:8086/DoAuthentication");

            TcpChannel chan2 = new TcpChannel();

            ChannelServices.RegisterChannel(chan2);
            FServer fServer = (FServer)Activator.GetObject(
                typeof(Lab13.FServer),
                "tcp://localhost:8085/DoFulfillment");



            try {
                bool passed = aServer.Authenticate(1234);
                Console.WriteLine(
                    "Authentication Server Customer 1234 Authorization: {0}",
                    passed.ToString());
                if (passed)
                {
                    bool shipped = fServer.Fulfill(1234, 5678);
                    Console.WriteLine(
                        "Fulfillment Server Customer 1234 Item Number 5678 Shipped: {0}",
                        shipped.ToString());
                }
            }
            catch (IOException ioExcep) {
                Console.WriteLine("Remote IO Error" +
                                  "\nException:\n" + ioExcep.ToString());
                return(1);
            }
            return(0);
        }
Esempio n. 31
0
        public void StartMasterServer()
        {
            System.Threading.Timer failDetectorTimer = null;
            try
            {
                string masterPort = ConfigurationManager.AppSettings[Constants.APPSET_MASTER_PORT];
                BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
                provider.TypeFilterLevel = TypeFilterLevel.Full;
                IDictionary props = new Hashtable();
                props[Constants.STR_PORT] = Int16.Parse(masterPort);
                masterChannel             = new TcpChannel(props, null, provider);
                master             = new PADI_Master();
                coordinator        = new PADI_Coordinator(master);
                master.Coordinator = coordinator;
                ChannelServices.RegisterChannel(masterChannel, false);
                RemotingServices.Marshal(master, Constants.OBJECT_TYPE_PADI_MASTER, typeof(PADI_Master));
                RemotingServices.Marshal(coordinator, Constants.OBJECT_TYPE_PADI_COORDINATOR, typeof(PADI_Coordinator));
                Thread notificationThread = new Thread(new ThreadStart(master.ViewChangeHandler));
                notificationThread.Start();
                failDetectorTimer = new System.Threading.Timer(master.DetectObjectServerFailure, null, long.Parse(ConfigurationManager.AppSettings[Constants.APPSET_OBJ_SERVER_FAIL_DECTOR_FREQUENCY]), long.Parse(ConfigurationManager.AppSettings[Constants.APPSET_OBJ_SERVER_FAIL_DECTOR_FREQUENCY]));

                Console.WriteLine("Master server started at port : " + masterPort);
                Common.Logger().LogInfo("Master server started", "Port : " + masterPort, string.Empty);
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Master startup failed.." + ex.Message);
                Common.Logger().LogError("Master startup failed..", ex.Message, ex.Source);
            }
            finally
            {
                if (failDetectorTimer != null)
                {
                    failDetectorTimer.Dispose();
                }
            }
        }
Esempio n. 32
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (etatServeur)
            {
                if (chnl != null)
                {
                    ChannelServices.UnregisterChannel(chnl);
                    pbox.ImageLocation = "E:/on.png";
                    label1.Text        = "Serveur OFF";

                    etatServeur = false;
                }
            }
            else
            {
                BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
                provider.TypeFilterLevel = TypeFilterLevel.Full;
                IDictionary props = new Hashtable();
                props["port"] = 1235;

                chnl = new TcpChannel(props, null, provider);


                ChannelServices.RegisterChannel(chnl, false);


                RemotingConfiguration.RegisterWellKnownServiceType(typeof(IEtudiantImpl), "ObjEtudiant", WellKnownObjectMode.SingleCall);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(IEnseignantImpl), "ObjEnseignant", WellKnownObjectMode.SingleCall);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(IScolariteImpl), "ObjScolarite", WellKnownObjectMode.SingleCall);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(Authentification), "ObjAuthentification", WellKnownObjectMode.SingleCall);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(NotificationClass), "ObjNotification", WellKnownObjectMode.Singleton);

                pbox.ImageLocation = "E:/off.png";
                label1.Text        = "Serveur ON";

                etatServeur = true;
            }
        }
Esempio n. 33
0
        /// <summary>
        /// Registers remoting channel if needed. This is determined
        /// by checking whether there is a positive value for port.
        /// </summary>
        protected virtual void RegisterRemotingChannelIfNeeded()
        {
            if (port > -1 && channelType != null)
            {
                // try remoting bind

                IDictionary props = new Hashtable();
                props["port"] = port;
                props["name"] = channelName;

                // use binary formatter
                BinaryServerFormatterSinkProvider formatprovider = new BinaryServerFormatterSinkProvider(props, null);
                formatprovider.TypeFilterLevel = typeFilgerLevel;

                string channelRegistrationKey = channelType + "_" + port;
                if (registeredChannels.ContainsKey(channelRegistrationKey))
                {
                    return;
                }
                IChannel chan;
                if (channelType == ChannelTypeHttp)
                {
                    chan = new HttpChannel(props, null, formatprovider);
                }
                else if (channelType == ChannelTypeTcp)
                {
                    chan = new TcpChannel(props, null, formatprovider);
                }
                else
                {
                    throw new ArgumentException("Unknown remoting channel type '" + channelType + "'");
                }

                ChannelServices.RegisterChannel(chan, false);

                registeredChannels.Add(channelRegistrationKey, new object());
            }
        }
        public static void Main(string[] args)
        {
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();

            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            var props = new Hashtable();

            props["port"] = 12345;

            var channel = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel, false);

            var service = new ServerService();

            RemotingServices.Marshal(service, "Curse");
            Console.WriteLine("Server started ...");
            Console.WriteLine("Press <enter> to exit...");
//			var count = service.GetAllDestinatii().Length;
//			Console.WriteLine(count);
            Console.ReadLine();
        }
Esempio n. 35
0
        private static void StartChannel()
        {
            TcpChannel tcpChannel = new TcpChannel(8080);

            ChannelServices.RegisterChannel(tcpChannel, true);

            //添加服务跟踪
            TrackingServices.RegisterTrackingHandler(new MyTrackingHandler());
            //注册远程对象
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(ServerObject), "ServiceMessage", WellKnownObjectMode.SingleCall);

            ObjRef objRef = RemotingServices.Marshal(new ServerFactory(), "FactoryService");

            //RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerObject),
            //    "ServiceMessage",WellKnownObjectMode.Singleton);

            //RemotingConfiguration.ApplicationName = "ServiceMessage";
            //RemotingConfiguration.RegisterActivatedServiceType(typeof(ServerObject));

            Console.WriteLine("Remoting服务启动,按退出...");
            Console.ReadLine();
        }
Esempio n. 36
0
        private void btnDesconectar_Click(object sender, EventArgs e)
        {
            //me livro do socket do chat
            if (meuSocket != null && meuSocket.Connected)
            {
                meuSocket.Shutdown(SocketShutdown.Both);
                System.Threading.Thread.Sleep(10);
                meuSocket.Close();
            }
            // e tambem do socket do RPC
            if (RPCchan != null)
            {
                ChannelServices.UnregisterChannel(RPCchan);
                RPCchan         = null;
                objetoRemotavel = null;
            }

            btnConectar.Enabled    = true;
            btnDesconectar.Enabled = false;
            btnSair.Enabled        = true;
            gbChat.Enabled         = false;
            gbRPC.Enabled          = false;
        }
Esempio n. 37
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();

            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            IDictionary props = new Hashtable();

            props["port"] = 0;
            TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel, false);
            IServerService server =
                (IServerService)Activator.GetObject(typeof(IServerService), "tcp://localhost:55555/server");

            ClientController ctrl = new ClientController(server);
            LogIn            win  = new LogIn(ctrl);

            Application.Run(win);
        }
Esempio n. 38
0
        public void Connect()
        {
            MarshalObject objMarshal = NewMarshalObject();

            IDictionary props = new Hashtable();

            props["name"] = objMarshal.Uri;
            props["port"] = 1236;
            TcpChannel chn = new TcpChannel(props, null, null);

            ChannelServices.RegisterChannel(chn);

            RemotingServices.Marshal(objMarshal, objMarshal.Uri);

            MarshalObject objRem = (MarshalObject)RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);

            Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A08");

            ChannelServices.UnregisterChannel(chn);

            // TODO: uncomment when RemotingServices.Disconnect is implemented
            //RemotingServices.Disconnect(objMarshal);
        }
Esempio n. 39
0
 static void Main()
 {
     try
     {
         //select channel to communicate
         TcpChannel channel = new TcpChannel(8090);
         ChannelServices.RegisterChannel(channel, false);
         //register channel
         //register remote object
         RemotingConfiguration.RegisterWellKnownServiceType(
             typeof(ProductDao), // ProductDao.class
             "Products",         // Url
             WellKnownObjectMode.SingleCall
             );
         //inform console
         Console.WriteLine("Server Activated ...");
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error : " + ex.Message);
     }
     Console.ReadKey();
 }
Esempio n. 40
0
        public virtual void Start()
        {
            if (uri != null && uri != string.Empty)
            {
                lock (theLock)
                {
                    this.channel = ServerUtilities.GetTcpChannel(uri + "Channel", port, 100);

                    RemotingServices.Marshal(this, uri);
                    this.isMarshalled = true;
                }

                if (this.port == 0)
                {
                    ChannelDataStore store = this.channel.ChannelData as ChannelDataStore;
                    if (store != null)
                    {
                        string channelUri = store.ChannelUris[0];
                        this.port = int.Parse(channelUri.Substring(channelUri.LastIndexOf(':') + 1));
                    }
                }
            }
        }
        private void radioButton_serverOnline_CheckedChanged(object sender, EventArgs e)
        {
            pb_serverStatus.Image = global::Vendas.View.Properties.Resources.Network_Alt;

            try
            {
                TcpChannel myIp = new TcpChannel(8080);
                //TcpServerChannel myIp = new TcpServerChannel("192.168.2.100", 8080);

                ChannelServices.RegisterChannel(myIp, false);

                Type commonInterfaceType = Type.GetType("Vendas.View.Services");

                var teste = Type.GetType("Vendas.Server.View.Services");

                RemotingConfiguration.RegisterWellKnownServiceType(commonInterfaceType, "Services", WellKnownObjectMode.SingleCall);

                Hide();

                notifyIcon_ServerApp.ShowBalloonTip(100, "Information", "Servidor ativo.", ToolTipIcon.Info);
            }
            catch (Exception ef) { MessageBox.Show("Erro: " + ef.Message); }
        }
Esempio n. 42
0
        static void Main(string[] args)
        {
            try
            {
                // Demarer le code qui gere les reservation expirées
                ReservationExpirationHandler.start();

                // Publier les objet
                TcpChannel chnl = new TcpChannel(1234);
                ChannelServices.RegisterChannel(chnl, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(FournisseurServiceCompte),
                                                                   "FournisseurServiceCompte", WellKnownObjectMode.Singleton);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(FournisseurServiceOuvrague),
                                                                   "FournisseurServiceOuvrague", WellKnownObjectMode.Singleton);

                Console.WriteLine("Serveur démarré...");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Serveur:Erreur d'initialisation !" + ex.Message);
            }
        }
Esempio n. 43
0
    public static void Main()
    {
        // <Snippet2>
        TcpChannel channel = new TcpChannel(9000);

        ChannelServices.RegisterChannel(channel);

        SampleWellKnown objectWellKnown = new SampleWellKnown();

        // After the channel is registered, the object needs to be registered
        // with the remoting infrastructure.  So, Marshal is called.
        ObjRef objrefWellKnown = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri");

        Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI);

        Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.");
        Console.ReadLine();
        RemotingServices.Disconnect(objectWellKnown);

        Console.WriteLine("Press enter to end the server process.");
        Console.ReadLine();
        // </Snippet2>
    }
Esempio n. 44
0
        public void init(string EntryURL)
        {
            string urlWorker = EntryURL;
            string urlMaster = "tcp://localhost:20001/PM";

            TcpChannel channel = new TcpChannel(10001);

            ChannelServices.RegisterChannel(channel, false);

            clientService = new ClientService();
            RemotingServices.Marshal(clientService, "C", typeof(ClientService));

            master = (IMaster)Activator.GetObject(
                typeof(IMaster), urlMaster);

            worker = (IWorker)Activator.GetObject(
                typeof(IWorker), urlWorker);

            worker.setJobTracker(true);

            System.Console.WriteLine("The worker URL is " + urlWorker);
            System.Console.WriteLine("The master URL is " + urlMaster);
        }
Esempio n. 45
0
        static async Task Main(string[] args)
        {
            studentLogic = new StudentLogic();
            courseLogic  = new CourseLogic();
            Protocol     = new Protocol();
            serverSocket = ConfigServer();
            clients      = new List <Utils.StudentSocket>();
            string queuePath = ConfigurationManager.AppSettings["LocalPrivateQueue"];

            logs = new LogsLogic(queuePath);
            var remotingServiceTcpChannel = new TcpChannel(7000);

            ChannelServices.RegisterChannel(
                remotingServiceTcpChannel,
                false);
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(CourseLogic),
                "courseLogicService",
                WellKnownObjectMode.SingleCall);
            await Task.Run(() => ListenClients(serverSocket).ConfigureAwait(false));

            await Task.Run(() => ShowMenu());
        }
Esempio n. 46
0
        private static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Port number required");
                return(1);
            }

            int port = Int32.Parse(args[0]);

            TcpChannel channel = new TcpChannel(port);

            ChannelServices.RegisterChannel(channel, true);

            PcsManager manager = new PcsManager();

            RemotingServices.Marshal(manager, "PCS");

            Console.WriteLine("PCS listening on port " + port);
            Console.ReadLine();

            return(0);
        }
Esempio n. 47
0
        static void Main(string[] args)
        {
            var Server = new TcpChannel(1000000);

            Server.EventInform += (sender, packet) => Console.WriteLine(packet.Message);
            Server.GetInform += (sender, packet) => Console.WriteLine("Got: {0}", packet.Value);
            Server.CheckInform += (sender, packet) =>
            {
                //if(!packet.Success)
                    Console.WriteLine("[{0}] {1} => {2}", packet.Success ? "SUCCESS" : "FAIL", packet.Key, packet.Value);
            };

            Server.GetAllInform += async (sender, packet) =>
            {
                Console.WriteLine("Test: Data Coherence Test...");
                foreach (var entity in packet.Table)
                    await Server.Check(entity.Key, entity.Value);
            };

            Server.Connected += async (sender) =>
            {
                Console.WriteLine("Connected");
                await sender.GetAll();
            };

            Server.Disconnected += (sender, error) =>
            {
                Console.WriteLine("Disconnected : {0}", error);
            };

            Task.Run(async () => await Server.Connect("127.0.0.1", 8002));

            Console.WriteLine("Press any key to exit..");
            Console.ReadKey();
            Server.Disconnect();
        }
Esempio n. 48
0
    /// <summary>
    /// Access the .NET Remoting server using code.
    /// </summary>
    static void RemotingClientByCode()
    {
        /////////////////////////////////////////////////////////////////////
        // Create and register a channel (TCP channel in this example) that
        // is used to transport messages across the remoting boundary.
        //

        // Properties of the channel
        IDictionary props = new Hashtable();
        props["typeFilterLevel"] = TypeFilterLevel.Full;

        // Formatters of the messages for delivery
        BinaryClientFormatterSinkProvider clientProvider =
            new BinaryClientFormatterSinkProvider();
        BinaryServerFormatterSinkProvider serverProvider =
            new BinaryServerFormatterSinkProvider();
        serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

        // Create a TCP channel
        TcpChannel tcpChannel = new TcpChannel(props, clientProvider,
            serverProvider);

        // Register the TCP channel
        ChannelServices.RegisterChannel(tcpChannel, true);

        /////////////////////////////////////////////////////////////////////
        // Create a remotable object.
        //

        // Create a SingleCall server-activated object
        SingleCallObject remoteObj = (SingleCallObject)Activator.GetObject(
            typeof(SingleCallObject),
            "tcp://localhost:6100/SingleCallService");

        // [-or-] a Singleton server-activated object
        //SingletonObject remoteObj = (SingletonObject)Activator.GetObject(
        //    typeof(SingletonObject),
        //    "tcp://localhost:6100/SingletonService");

        // [-or-] a client-activated object
        //RemotingConfiguration.RegisterActivatedClientType(
        //    typeof(ClientActivatedObject),
        //    "tcp://localhost:6100/RemotingService");
        //ClientActivatedObject remoteObj = new ClientActivatedObject();

        /////////////////////////////////////////////////////////////////////
        // Use the remotable object as if it were a local object.
        //

        string remoteType = remoteObj.GetRemoteObjectType();
        Console.WriteLine("Call GetRemoteObjectType => {0}", remoteType);

        Console.WriteLine("The client process and thread: {0}, {1}",
            GetCurrentProcessId(), GetCurrentThreadId());

        uint processId, threadId;
        remoteObj.GetProcessThreadID(out processId, out threadId);
        Console.WriteLine("Call GetProcessThreadID => {0} {1}", processId, threadId);

        Console.WriteLine("Set FloatProperty += {0}", 1.2f);
        remoteObj.FloatProperty += 1.2f;

        Console.WriteLine("Get FloatProperty = {0}", remoteObj.FloatProperty);
    }
Esempio n. 49
0
    /// <summary>
    /// Create the .NET Remoting server using code.
    /// </summary>
    static void RemotingServerByCode()
    {
        /////////////////////////////////////////////////////////////////////
        // Create and register a channel (TCP channel in this example) that
        // is used to transport messages across the remoting boundary.
        //

        // Properties of the channel
        IDictionary props = new Hashtable();
        props["port"] = 6100;   // Port of the TCP channel
        props["typeFilterLevel"] = TypeFilterLevel.Full;

        // Formatters of the messages for delivery
        BinaryClientFormatterSinkProvider clientProvider = null;
        BinaryServerFormatterSinkProvider serverProvider =
            new BinaryServerFormatterSinkProvider();
        serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

        // Create a TCP channel
        TcpChannel tcpChannel = new TcpChannel(props, clientProvider,
            serverProvider);

        // Register the TCP channel
        ChannelServices.RegisterChannel(tcpChannel, true);

        /////////////////////////////////////////////////////////////////////
        // Register the remotable types on the service end as
        // server-activated types (aka well-known types) or client-activated
        // types.
        //

        // Register RemotingShared.SingleCallObject as a SingleCall server-
        // activated type.
        RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(RemotingShared.SingleCallObject),// Server-activated type
            "SingleCallService",                    // objectUri
            WellKnownObjectMode.SingleCall);        // SingleCall mode

        // Register RemotingShared.SingletonObject as a Singleton server-
        // activated type.
        RemotingConfiguration.RegisterWellKnownServiceType(
            typeof(RemotingShared.SingletonObject), // Server-activated type
            "SingletonService",                     // objectUri
            WellKnownObjectMode.Singleton);         // Singleton mode

        // Register RemotingShared.ClientActivatedObject as a client-
        // activated type.
        RemotingConfiguration.ApplicationName = "RemotingService";
        RemotingConfiguration.RegisterActivatedServiceType(
            typeof(RemotingShared.ClientActivatedObject));
    }