Webservice consumption only runs on debugging under the Visual Studio IDE

0

My WinForms VB.NET application consumes a webservice to perform some queries. When running in debug or release mode under the Visual Studio IDE, it works perfectly, but once distributed on client computers (or even on my own, running straight from the executable), it fails with this message:

  

System.InvalidOperationException: The standard endpoint element that references the 'WsTrf3.InstallationService' agreement could not be located in the Client ServiceModel configuration section. This may have occurred because of the lack of a configuration file for your application or because no endpoint element corresponding to this agreement could be found in the client element.

I suppose something that is present during debugging is missing from the distribution, but I have no clue what. Any help would be greatly appreciated.

    
asked by anonymous 22.02.2017 / 14:51

2 answers

2

You are probably distributing your application without the configuration file (app.config) or the client configuration file does not have the ServiceModel key. The correct would be to include these settings in the configuration file of the client machine. This section probably exists within the app.config file in your visual studio project and does not exist in the [executable_name] .exe.config file on the client machine.

Check out more about these settings in Microsoft documentation.

    
22.02.2017 / 15:08
2

The friend Julio Borges warned me that I should distribute the app.config file together with the executable to resolve the problem. This is correct and therefore I will mark the answer.

But next to that, I'd like to alert you to another solution that I've discovered, and that I'll use because I'd like to keep the distribution restricted to a single file: you can deploy the configuration data directly in the code.

So I replaced:

Dim myclient as New MyServiceReference.MyServiceClient

by

Dim myclient as New MyServiceReference.MyServiceClient(
    New BasicHttpBinding(BasicHttpSecurityMode.None),
    New EndpointAddress("http://myservice.mysite.com/services/MyService.svc?wsdl"))

And voila, it worked.

Many thanks to all who tried to help me with this!

    
22.02.2017 / 15:48