locked
An unhandled exception of type 'System.InvalidOperationException'

    Question

  • I get the following error when I try to instantiate any of the SoapClient classes ( ex.

    CustomerManagementSoapClient csc = new CustomerManagementSoapClient(); )

     

    "An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll

    Additional information:
    An endpoint configuration section for contract '........CustomerManagementSoap' could not be loaded because more than one endpoint configuration for that contract was found.
    Please indicate the preferred endpoint configuration section by name."

     

    Here is how I generate my proxy classes:

    svcutil /l:cs /out:CustomerManagementService.cs /config:Customer.config /messageContract /namespace:*,MSNTool.MSNProvider.CustomerManagementService /targetClientVersion:Version30 https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/v5/CustomerManagement/CustomerManagement.asmx?wsdl

     

     

    What am I missing ?

    Tuesday, April 01, 2008 8:28 PM

Answers

  • Obviously there are 2 endpoints in the config file for each proxy class that is being generated. So if you call it with the default constructor as I did in the example above you get the abovementioned error, which means you have to instantiate it passing the name of the endpoint to the constructor.

    Thursday, April 03, 2008 4:34 PM

All replies

  • Obviously there are 2 endpoints in the config file for each proxy class that is being generated. So if you call it with the default constructor as I did in the example above you get the abovementioned error, which means you have to instantiate it passing the name of the endpoint to the constructor.

    Thursday, April 03, 2008 4:34 PM
  • I received the same error as above using visual studio. It seems the 2 endpoints generated in the config file by the svcutil program conflict with each other.

     

    My solution was to comment out one of the endpoints, but i'm not sure if that's a safe way to get around the error.

     

    Can you post your syntax for specifying the endpoint when you instantiate the class?

     

    Tuesday, April 15, 2008 5:04 PM
  •  

    You just pass the name of the endpoint you want to use when you instantiate the  class:

     

     

    CustomerManagementService.CustomerManagementSoapClient cm = new CustomerManagementSoapClient("CustomerManagementSoap");

     

    This way you don't have to touch the config file.

     

    Tuesday, April 15, 2008 5:19 PM