Geeks With Blogs
Random Musing Putting it together one piece at a time...

While developing WCF client/services, I frequently encounter this annoying error whenever I run my client to connect to the service contract for the first time. I term them as "timewasters". This post will partly serve as a reminder to me, and hopefully someone will benefit from it if they came across the same problem.

The story goes like this, you start up your usual Visual Studio 2005 to work on a simple WCF's application (you know the usual service <-> client stuffs). So you created your service and named your interface IContact with a namespace called Contact

namespace Contact
    public interface IContact
        void Something();

You then go on to create your configuration and service file, opened up your IIS, create a virtual directory and dumped the appropriate files into the virtual directory. You then test the directory from your Internet Explorer.

Everything works beautifully. So now you do the easy part.

Fire up the SDK command prompt and use the "svcutil" command to create the proxy needed for connection to the service. You create a client project, add the auto-generated proxy and output.config file and start to consume the service via the proxy you've just created. After all is done, you do a run and this came staring at you

So what's wrong? It's all spelled out in the error description actually. The resolution is pretty simple, here's something you can take note so that this error message will be gone for good

  1. Use full names for your proxy, config files and code calls instead of just the interface name. (NamespaceName.InterfaceName instead of just IntefaceName, "svcutil" will only provide you with the InterfaceName)
  2. Name your config file correctly (web application uses web.config, desktop applications uses app.config)

I guess if someone ran into the same problem again as I do, they might benefit from this post.

Posted on Friday, January 5, 2007 12:50 PM .Net , Connected Systems | Back to top

Comments on this post: That annoying "Could not find endpoint element with name..." error

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
Thanks posting.
i have app.config and also resolved scope with namespaces for interface,but i'll still running into issue.

I'm using win2k3.

Left by Raghav on Jan 17, 2008 11:43 AM

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
The endpoint's name atribute should be set exactly to the string that is passed to the constructor of the proxy. The contract atribute should be fully qualifyed with the namespace name. Ex: "MyClientns.IMyContract"
Left by Zoli on Aug 08, 2008 8:10 PM

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
This issue is driving me nuts over here.

I simply used the "add service reference" feature in VS-2008 and thought the silly thing was able to configure all I need from the web service reference. I thought having the ability to configure an endpoint in app.config (it's a winforms app) would be nice so one wouldn't have to recompile just because the service moved to a new address, but as it's a pet project for my personal use it wasn't exactly of the utmost importance.

The "add service reference" feature does seem to work and it generates the proxy and all the supporting types, but at run-time complains that it cannot find a "default endpoint" with the contract in question. I don't know why no default endpoint was configured when I added the service reference, but I added the system.serviceModel configuration and defined an endpoint named "BFG", use the constructor for the proxy that takes an endpoint name, and defined the contract name as it appears in the error message (with namespace name, but not fully qualified - though I tried both with the same result).

The stupid configurationexception doesn't bother to say if the problem was it didn't find the endpoint or it had the wrong contract, so it's not exactly as helpful as it could be. Since fully-qualified contract name also failed I can only assume the problem is that the endpoint isn't found. So then it must be the service name - but of course the exception doesn't bother to tell you that either.

How lazy can one allow oneself to be when writing library code tens of thousands of programmers will be using!? In my view, not including essential information when throwing exceptions is simply unforgiveable. My patience is long gone...

<service name="BFGlobalService">
<endpoint name="BFG" address="" contract="BetFair.BFGlobalService" binding="basicHttpBinding" />

// Can't find endpoint, even if it's the ONLY one...
globalService = new BetFair.BFGlobalServiceClient("BFG");
Left by Northener on Oct 02, 2009 9:03 AM

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
The problem is often that the library calling the web service (the library which has an app.config file) is not the host process. The app.config file has to be copied to any process which depends on the library actually calling the web service. If gui.exe loads webserviceclient.dll, there should be a serviceModel config section in both gui.exe.config and webserviceclient.dll.config.
Left by Publius on Oct 19, 2010 10:27 AM

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
Just ran into this four years after you wrote you it. thank you
Left by Gordon on May 15, 2011 1:13 PM

# re: That annoying "Could not find endpoint element with name..." error
Requesting Gravatar...
I had the same issue. svcutil.exe created a config file output.config which I had to rename to App.Config.

Additionally I had to initialize the proxy with the "name" of the endpoint as it appears in the name attribute in the App.config file. this was because I had 2 endpoints.
Left by niall on Aug 10, 2011 9:31 AM

Your comment:
 (will show your gravatar)

Copyright © Nestor | Powered by: