Thursday, January 13, 2011

WCF : Could not find default endpoint element that references contract

Working through the WCF samples, I came across the in-line calculator.

Built it according to the instructions (using Visual Studio 10 and .NET Framework 4), ran it up and got the following exception:


Could not find default endpoint element that references contract 'ICalculator' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.


A lot of communication with Mr. Google and then came across a comment way down in a blog entry that offered some hope.

To generate the proxies, you run:


svcutil.exe http://localhost/IISHostedCalc/service.svc?wsdl


This generates two files:

CalculatorService.cs
output.config

and you add them to your project using "Add Existing Item".

To get rid of the exception, simply rename "output.config" to "app.config" and ensure it is part of your project.

Enjoy!

No comments: