WCF Client Error: Could not find default endpoint element that references contract 'FDF_WCFService.IFDFOperations' in the ServiceModel client configuration section. RRS feed

  • Question

  • Hi,

    I have a .NET class library project (DLL) in C# that is referencing a WCF web service and calling its methods.  Everything works fine if I hard code the service endpoints in my DLL code like this:

    FDF_WCFService.FDFOperationsClient fdfWS;
            var binding = new BasicHttpBinding();
            var endpoint = new EndpointAddress("http://win-ptpxiy1x3ur/FDF_WCFService_4.0/FDF_WCFService.svc");
            fdfWS = new FDF_WCFService.FDFOperationsClient(binding, endpoint);

    However, I get the above error if I want to read endpoint from client configuration file that is generated by VS 2012. Ideally I would like to create the object of FDF_WCFService.FDFOperationsClient class that is exposed by WCF web service without hard coding web service endpoints like this:

       fdfWS = new FDFWebService.FDFService();
                fdfWS = new FDF_WCFService.FDFOperationsClient();

    Below is the default client config file (app.config) created by VS 2012 after I reference WCF web service and build the solution:

    <?xml version="1.0"?>
                    <binding name="defaultEp" />
                <endpoint address="http://win-ptpxiy1x3ur/FDF_WCFService_4.0/FDF_WCFService.svc"
                    binding="basicHttpBinding" bindingConfiguration="defaultEp"
                    contract="FDF_WCFService.IFDFOperations" name="defaultEp" />
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

    Please help what am I missing.  I've verified that the WCF web service is running fine at the given URL above. 



    Monday, February 10, 2014 9:30 PM


All replies

  • Hello VJ,

    Try removing name from the endpoint configuration or change to:

    fdfWS = new FDFWebService.FDFService();
    fdfWS = new FDF_WCFService.FDFOperationsClient("defaultEp");



    Tuesday, February 11, 2014 12:44 AM
  • Hi Jeff,

    Thanks for your response. I tried both ways but it's still not working.  When I put the endpoint name in code like you mentioned, the error changed to the following:

    Could not find endpoint element with name 'defaultEp' and contract 'FDF_WCFService.IFDFOperations' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element. 

    I guess this is very simple thing that I'm trying to do. Not sure what am I missing.  Please let me know what else I can try.



    Tuesday, February 11, 2014 3:11 AM
  • Hello VJ,

    Hmmm; not sure.  It is a client configuration issue because the error message is before any call to the service.

    My suggestion would be to create a new console app, add service reference again and without making any config edits create a new client.  Maybe you will see something in the config that is generated that we are not spotting because it looks ok to me.

    If it still does not work, could you post the config again?

    Sorry to not be able to help... 


    Tuesday, February 11, 2014 7:40 PM
  • Hi Jeff,

    I will definitely try your suggestion.  I think this issue could be due to the multi-layer architecture used by my app. I have an old C++ Windows service that invokes my .NET class library (DLL) which in turn calls this WCF web service. This error suggests that my class library can't even find the endpoint in the ServiceModel section of client config file.  So it might mean that my C++ Windows service is also trying to find its own client config file, but I am not sure if that supports app config file at all since it was written probably in Visual C++ 6 or earlier.

    If that's not the case, why can't my class library (WCFAdapter.dll) find endpoint info in its config file (WCFAdapter.config) which I have copied in the same folder on the target machine ?  Can you confirm if WCFAdapter.config is the correct config file name for class library WCFAdapter.dll ?



    Wednesday, February 12, 2014 2:31 PM
  • That explains things a bit differently.  The config file is not being read; by default the config will be the exe's config and not a referenced libary.  Try renaming the config to the exe name but I am not sure off hand with C++. 

    If it does not work then you can either read from a file:

    Or set the config setttings in code:


    Wednesday, February 12, 2014 8:10 PM