Developing Windows Applications by Mykola Dudar

Helping Developers Build Applications for Windows using Visual Studio.

Troubleshooting "'An endpoint configuration section for contract could not be loaded because more than one endpoint configuration for that contract was found" error

Troubleshooting "'An endpoint configuration section for contract could not be loaded because more than one endpoint configuration for that contract was found" error

  • Comments 3

While I was playing with Microsoft AdCenter API, I have encountered this error:

Error 'An endpoint configuration section for contract 'Microsoft.AdCenter.ICampaignManagementService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.' encountered.

Out of curiosity, I searched the web for guidance to troubleshoot this error. Surprisingly, I have found very confusing posts of forums with no clear guidance on how to fix the problem. However there seems to be a very simple solution in VS2008 SP1, unless I am missing something.

  1. Open app.config file and check the list of bindings for the service
  2. Pick one binding and copy it to your source as a parameter to a constructor of Service Client class created by "Service Reference" dialog.

That's it. In my example, the app.config file looked like this:

image

Now I was going to use HTTPS connection to the service and as such I am choosing to use "BasicHttpBinding_ICampaignManagementService" binding, which means modifying source code from:

             svcCampMgt = new CampaignManagementServiceClient();

to

             svcCampMgt = new CampaignManagementServiceClient("BasicHttpBinding_ICampaignManagementService");

This change complete fixes the problem. Now some WCF guru can probably point out several other reasons for this error, but hey, for simple scenarios, this change should fix the error just fine.

  • Hi, thanks for the solution.

    This is why this error occurs:

    Visual Studio generates the end points in the app.config when you refresh your service reference. If your end point has been modified inside the app.config file it creates a second end point, and that is what causes the problem.

    So to fix this, simply select the one you want to keep, look in the <basicHttpBinding> node of the file, and delete everything between <binding.name...> and </binding>, you'll notice that you have two of those, only delete one of them.

    Do the same for the <Client> node of the file.

    Unfortunately Visual Studion will generate that code everytime you update the service reference, so you'll have to remove it again every time.

    Your solution is the best one in this case, and if you deliberately have two endpoint, eg. to include one for over http etc.

    Cheers!

  • Thank you so much. I had no idea how to find out what the endpoint names ...

  • usally means that you to refrences in your web.config..Good Luck

Page 1 of 1 (3 items)