Search This Blog

Tuesday, January 15, 2013

"Could not find endpoint element with name ..." WCF error

I developed a windows service which periodically polls a WCF server for information -- I added a service reference to the project which provided a proxy for a "ProvisioningClient" object.  The could would instantiate this object and then perform tasks:

using (ProvisioningClient client = new ProvisioningClient("basic")
{
   // Do stuff
}

The way I create windows services is to first create a DLL that performs all of the work and then load and call it from a C# windows project.

For debugging, though, I put together a simple Windows form test harness (just a single form in a project called "Service Impersonator") with a single "Start DLL" button which loads the DLL and lets me interactively debug the DLL code.

The program would consistently fail on the "using" statement above, though, with a message:

Could not find endpoint element with the name 'basic' and contract 'ExchangeProvisioningServiceReference.IExchangeProvisioning' in the ServiceModel client configuration section...

I'd check the APP.CONFIG file in the DLL and there was indeed an endpoint element called 'basic' following that very contract; reviewing the WEB.CONFIG file of the WCF service showed that the syntax matched perfectly.

Since the code failed in the DLL and the error pointed to the APP.CONFIG file, that's where I kept looking and puzzling.  The problem was not there but in the Winform test harness project:  it was a very simple project which just called the DLL but for some reason the DLL looked for an APP.CONFIG file in the .EXE file calling it and, not finding one, gave me that message.

Adding a service reference to the Winform test harness project that called the DLL resolved the problem.  I don't understand why the DLL doesn't look at its own APP.CONFIG file but that's the way it is.

1 comment:

David Graper said...

Here's a related link which describes the same problem. It also features some relevant additional links inside the posting that are of some interest.

http://stackoverflow.com/questions/3188965/could-not-find-endpoint-element-with-name