Search code examples
wcfwcf-endpointwcfserviceclient

creating the wcf service client causes a InvalidOperationException


I have 2 solutions:

In solution 1 I have a web project with wcf service references. In solution 2 I have a wpf project where I start the following wcf client:

When I create an instance of my wcf client:

using (var client = new LSKTicketServiceReference.LSKTicketServiceClient())
{
   // client.do()
}

I get this error:

"Could not find default endpoint element that references contract 'LSKTicketServiceReference.ILSKTicketService'..."

But in the app.config of the facade project used by the wpf project I have this endpoint defined:

 <system.serviceModel>
    <bindings>
      <basicHttpBinding>      
        <binding name="BasicHttpBinding_ILSKTicketService" />
      </basicHttpBinding>
    </bindings>
    <client>

      <endpoint address="http://localhost:53776/LSKTicketService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILSKTicketService" contract="ILSKTicketService" name="BasicHttpBinding_ILSKTicketService" />
    </client>
  </system.serviceModel>

So what is the problem here? I defined my endpoint.


Solution

  • The problem was NOT that the creation of the LSKTicketServiceClient was created in a Facade project.

    But that the Facade project was referenced by the WPF app project and here was the endpoint configuration missing in the app.config.