WCF error: could not find default end point element that references contract

I was trying to consume an IIS hosted WCF service, got this error “could not find default end point element that references contract in the ServiceModel client configuration. This might be because no endpoint element matching this contract could be found in the client element”.

I fixed it by performing the following steps:-

1. Included the following namespace in the WCF client component

using System.ServiceModel;
using System.Runtime.Serialization;

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

If the WCF client project is of type .NET 3.5 or higher, it will have references to System.ServiceModel.dll and System.Runtime.Serialization.dll. It will not have references to those namespaces in the code, this needs to be added.

2. Changed the name of the client configuration file from ‘output.config’ to ‘app.config’. When I generated client proxy using svcutil.exe, I set the default name of output.config and this needs to be changed to ‘app.config’.If your client is a web application, you can copy the contents inside System.ServiceModel to the web.config

After doing the above 2 steps, my WCF client worked like a charm.

 Subscribe to my blog

One thought on “WCF error: could not find default end point element that references contract

  1. Pingback: WCF error: could not find default end point element that references contract - My experiments with SharePoint, Azure and .NET using Visual Studio

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.