static void Main(string[] args)
        {
            // Determine the system connectivity mode based on the command line
            // arguments: -http, -tcp or -auto  (defaults to auto)
            ServiceBusEnvironment.SystemConnectivity.Mode = GetConnectivityMode(args);

            Console.Write("Your Service Namespace: ");
            string serviceNamespace = Console.ReadLine();

            Console.Write("Your Issuer Name: ");
            string issuerName = Console.ReadLine();

            Console.Write("Your Issuer Secret: ");
            string issuerSecret = Console.ReadLine();

            // create the service URI based on the service namespace
            Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

            // create the credentials object for the endpoint
            TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();

            sharedSecretServiceBusCredential.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuerName, issuerSecret);

            // create the channel factory loading the configuration
            BalancingChannelFactory <IEchoChannel> channelFactory = new BalancingChannelFactory <IEchoChannel>(new NetTcpRelayBinding(EndToEndSecurityMode.None, RelayClientAuthenticationType.RelayAccessToken), new EndpointAddress(serviceUri));

            // apply the Service Bus credentials
            channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);


            Console.WriteLine("Enter text to echo (or [Enter] to exit):");
            string input = Console.ReadLine();

            while (input != String.Empty)
            {
                IEchoChannel channel = channelFactory.CreateChannel();
                channel.Open();

                try
                {
                    // create and open the client channel
                    Console.WriteLine("Server echoed: {0}", channel.Echo(input));
                    channel.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: " + e.Message);
                    channel.Abort();
                }


                input = Console.ReadLine();
            }

            channelFactory.Close();
        }
        static void Main(string[] args)
        {
            Console.Write("Enter the Service Namespace you want to connect to: ");
            string serviceNamespace = Console.ReadLine();

            Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

            ChannelFactory <IEchoChannel> channelFactory = new ChannelFactory <IEchoChannel>("RelayEndpoint", new EndpointAddress(serviceUri, EndpointIdentity.CreateDnsIdentity("localhost")));

            channelFactory.Credentials.UserName.UserName = "******";
            channelFactory.Credentials.UserName.Password = "******";

            IEchoChannel channel = channelFactory.CreateChannel();

            try
            {
                channel.Open();


                Console.Write("Enter the text to echo (or press [Enter] to exit): ");
                string input = Console.ReadLine();
                while (input != String.Empty)
                {
                    try
                    {
                        Console.WriteLine("Server echoed: {0}", channel.Echo(input));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error: " + e.Message);
                    }
                    input = Console.ReadLine();
                }

                channel.Close();
            }
            finally
            {
                channel.Abort();
            }
            channelFactory.Close();
        }