C# – “Could not find default endpoint element that references contract”

csoapsoap-clientweb services

Yes, I know the question is probably a repeat, but bear with me here. I've tried what I've seen in ALL other questions of the same type and STILL haven't managed to get this working.

I'm working with .Net 4.0 in VS2012 Ultimate. I have a class library that's supposed to reference a web service. Going through the usual steps (Add Service Reference > enter service URI > Go > find the available service > give it a name > OK) creates the service reference and adds a system.serviceModel tag in the app.config file of my class library.

This class library is currently being referenced by a WinForms app that's passing data to it, to be validated with the returned data from web service. However, upon creation of the service client object…

SHWS.StaticXMLAPISoapClient wsc =
    new SHWS.StaticXMLAPISoapClient();

…the code crashes with the error noted in the question title, "Could not find default endpoint element that references contract 'SHWS.StaticXMLAPISoap' 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 contract could be found in the client element."

I have tried EVERYTHING I've found on the net, from copying the [class library name].dll.config file to the output folder of the WinForms app, to copying the system.serviceModel tag from one config file to the other, and still no luck.

I'm literally at my wit's end. Any help would be VERY appreciated, since this is one of the key points of the app I'm working on at the moment. Apologies for my ridiculous request, and thanks in advance for your time.

Best Answer

Have you tried adding the same system.serviceModel sections/settings to your WinForms app.config file ?

Related Topic