Could not find default endpoint element that refer

2019-07-27 13:18发布

问题:

I created an eBay console app that runs from a service. If I run the console as is, it works fine. If I don't run it as it I get 'Could not find default endpoint element that references contract 'EbayFinding.FindingServicePortType' in the ServiceModel client configuration section.

I've tried fully qualifying my app.config but that didn't seem to fix it, does anybody have any ideas?

 <endpoint address="https://svcs.ebay.com/services/search/FindingService/v1"
            binding="basicHttpBinding" bindingConfiguration="FindingServiceSOAPBinding"
            contract="EbayFindingConsole.EbayFinding.FindingServicePortType" name="FindingServiceSOAPPort" />
    </client>

contract="FindingServicePortType" (is the original state)

Code that calls the contract:

using (FindingServicePortTypeClient client = new FindingServicePortTypeClient())

回答1:

The rest of the error message is:

This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

Since it is working when run directly, we can rule out that endpoint is missing. The only thing that remains is that configuration file is not where it is being searched for.

Check whether the directory from which you are running the console app has the configuration file for console app.

If the console app and service executable are in same directory, that directory should contain the console app configuration file.