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;
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.