In Focus

Forums - C# Corner

Forum guidelines
Chris Dunn

Chris Dunn

  • 1.6k
  • 2
  • 4.4k

Problem with Service Endpoint Definition

Dec 16 2012 9:02 AM

I am attempting a .NET Framework 4.5 Getting Started tutorial on WCF. I have created the application in Visual Studio 2012 Ultimate on a Windows 7 Professional 64 bit machine.

The URL to the tutorial step where I am having the issue:

I have followed all four of the steps laid out under 'To create a new console application to host the service'.

When I get down to 'To verify the service is working', I can debug 'GettingStartedHost', and the console window opens. The problem is that if I go to the debug page of


I've also tried to modify the URL to use 'GettingStartedHost' and 'GettingStartedLib' instead of 'GettingStarted'.

I get a 404 error that the web page cannot be found. If I bring up the WCF Service Host window, it shows that the GettingStartedLib.CalculatorService has been stopped. When I select the service, 'Additional Information' shows the following:

"The service cannot be started. This service has no endpoint defined. Please add at least one endpoint for the service in config file and try again."

Program.cs has the service endpoint defined in a try/catch like this:

                // Step 3 Add a service endpoint.
                selfHost.AddServiceEndpoint(typeof(ICalculator), new WSHttpBinding(), "CalculatorService");

                // Step 4 Enable metadata exchange.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;

                // Step 5 Start the service.
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");

                // Close the ServiceHostBase to shutdown the service.
            catch (CommunicationException ce)
                Console.WriteLine("An exception occurred: {0}", ce.Message);

Why would there be a problem with the Service Endpoint? The tutorial states that with .NET 4.5 that I don't even need to specify the endpoint.

Thank you for your help.


Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now