public static void Main(string[] args)
    {
        // Create the channel.
        HttpClientChannel clientChannel = new HttpClientChannel();

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

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

        RemotingConfiguration.RegisterWellKnownClientType(remoteType);

        // Create a message sink.
        string objectUri;

        System.Runtime.Remoting.Messaging.IMessageSink messageSink =
            clientChannel.CreateMessageSink(
                "http://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());
        }

        // Display the channel's properties using Keys and Item.
        foreach (string key in clientChannel.Keys)
        {
            Console.WriteLine(
                "clientChannel[{0}] = <{1}>",
                key, clientChannel[key]);
        }

        // Parse the channel's URI.
        string objectUrl  = "http://localhost:9090/RemoteObject.rem";
        string channelUri = clientChannel.Parse(objectUrl, out objectUri);

        Console.WriteLine("The object URL is {0}.", objectUrl);
        Console.WriteLine("The object URI is {0}.", objectUri);
        Console.WriteLine("The channel URI is {0}.", channelUri);

        // 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());
    }
    public static void Main()
    {
        try
        {
// <Snippet5>
            // Creating the 'IDictionary' to set the server object properties.
            IDictionary myDictionary = new Hashtable();
            myDictionary["name"]     = "HttpClientChannel";
            myDictionary["priority"] = 2;
            // Set the properties along with the constructor.
            HttpClientChannel myHttpClientChannel =
                new HttpClientChannel(myDictionary, new BinaryClientFormatterSinkProvider());
            // Register the server channel.
            ChannelServices.RegisterChannel(myHttpClientChannel);
            MyHelloServer myHelloServer1 = (MyHelloServer)Activator.GetObject(
                typeof(MyHelloServer), "http://localhost:8085/SayHello");
            if (myHelloServer1 == null)
            {
                System.Console.WriteLine("Could not locate server");
            }
            else
            {
                Console.WriteLine(myHelloServer1.myHelloMethod("Client"));
                // Get the name of the channel.
                Console.WriteLine("Channel Name :" + myHttpClientChannel.ChannelName);
                // Get the channel priority.
                Console.WriteLine("ChannelPriority :" + myHttpClientChannel.ChannelPriority.ToString());
                string myString, myObjectURI1;
                Console.WriteLine("Parse :" +
                                  myHttpClientChannel.Parse("http://localhost:8085/SayHello", out myString) + myString);
                // Get the key count.
                System.Console.WriteLine("Keys.Count : " + myHttpClientChannel.Keys.Count);
                // Get the channel message sink that delivers message to the specified url.
                IMessageSink myIMessageSink =
                    myHttpClientChannel.CreateMessageSink("http://localhost:8085/NewEndPoint",
                                                          null, out myObjectURI1);
                Console.WriteLine("The channel message sink that delivers the messages to the URL is : "
                                  + myIMessageSink.ToString());
                Console.WriteLine("URI of the new channel message sink is: " + myObjectURI1);
            }
// </Snippet5>
        }
        catch (Exception ex)
        {
            Console.WriteLine("The following exception is raised on client side :" + ex.Message);
        }
    }