Can't correct the error in this basic WCF Service hosted in a Console Application RRS feed

  • Question

  • I have a basic WCF Service hosted in a Console Application that I can't consume from another Console Application.

    I'm studying WCF so I'm trying to make it work to follow along with a book.

    When I try to consume the service I get the following error "Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/HelloWorldService that could accept the message. This is often caused by an incorrect address or SOAP action..."

    But the service runs well:

    I'm using VS2012.

    The general structure of the solution is:

    HelloWorldService is the service, HostCmdLineApp hosts the service and HelloWorldClient consumes it.

    In HostCmdLineApp (the service Host), the service is described in the App.config file with:

            <service name="MyWCFServices.HelloWorldService"
                <endpoint address="HelloWorldService"
                            contract="MyWCFServices.IHelloWorldService" />
                <endpoint address="mex"
                            contract="IMetadataExchange" />
                <behavior name="HelloWorldServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>

    The Main method that publishes the service from HostCmdLineApp is:

    static void Main(string[] args) {
        var baseAddress = new Uri("http://localhost:6599/HostCmdLineApp/HelloWorldService.svc");
        using (var host = new ServiceHost(typeof(MyWCFServices.HelloWorldService), baseAddress)) {
            Console.WriteLine("HelloWorldService is ready to be used. ");
            Console.WriteLine("Press <ENTER> to terminate service.");

    The App.config file of HelloWorldClient (the service consumer) was generated by the SvcUtil tool:

                <binding name="BasicHttpBinding_IHelloWorldService" />
            <endpoint address="http://localhost:6599/HostCmdLineApp/HelloWorldService.svc/HelloWorldService"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHelloWorldService"
                contract="IHelloWorldService" name="BasicHttpBinding_IHelloWorldService" />

    And the Main method that consumes the service is:

    static void Main(string[] args) {
        var client = new HelloWorldServiceClient();
        Console.WriteLine(client.GetMessage("Rafael Soteldo"));

    I ran VS as Administrator.

    Believe you can do it, and you will!!

    Monday, February 24, 2014 10:22 PM