public static int PublishService(int port)
        {
            // Get a free port
            TcpListener listener = new TcpListener(IPAddress.Loopback, port);

            listener.Start();
            if (port == 0)
            {
                port = ((IPEndPoint)listener.LocalEndpoint).Port;
            }
            listener.Stop();

            Hashtable dict = new Hashtable();
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

            dict ["port"] = port;
            serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            ChannelServices.RegisterChannel(new TcpChannel(dict, clientProvider, serverProvider), false);
            publicPort = port;

            InstrumentationServiceBackend backend = new InstrumentationServiceBackend();

            System.Runtime.Remoting.RemotingServices.Marshal(backend, "InstrumentationService");

            return(port);
        }
		public static int PublishService ()
		{
			RemotingService.RegisterRemotingChannel ();
			TcpChannel ch = (TcpChannel) ChannelServices.GetChannel ("tcp");
			Uri u = new Uri (ch.GetUrlsForUri ("test")[0]);
			publicPort = u.Port;
			
			InstrumentationServiceBackend backend = new InstrumentationServiceBackend ();
			System.Runtime.Remoting.RemotingServices.Marshal (backend, "InstrumentationService");
			
			return publicPort;
		}
        public static int PublishService()
        {
            RemotingService.RegisterRemotingChannel();
            TcpChannel ch = (TcpChannel)ChannelServices.GetChannel("tcp");
            Uri        u  = new Uri(ch.GetUrlsForUri("test")[0]);

            publicPort = u.Port;

            InstrumentationServiceBackend backend = new InstrumentationServiceBackend();

            System.Runtime.Remoting.RemotingServices.Marshal(backend, "InstrumentationService");

            return(publicPort);
        }
		public static int PublishService (int port)
		{
			// Get a free port
			TcpListener listener = new TcpListener (IPAddress.Loopback, port);
			listener.Start ();
			if (port == 0)
				port = ((IPEndPoint)listener.LocalEndpoint).Port;
			listener.Stop ();
			
			Hashtable dict = new Hashtable ();
			BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
			BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
			dict ["port"] = port;
			serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
			ChannelServices.RegisterChannel (new TcpChannel (dict, clientProvider, serverProvider), false);
			publicPort = port;
			
			InstrumentationServiceBackend backend = new InstrumentationServiceBackend ();
			System.Runtime.Remoting.RemotingServices.Marshal (backend, "InstrumentationService");
			
			return port;
		}