Webservice consumption only runs in debugging under the Visual Studio IDE

Asked

Viewed 1,130 times

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 it’s distributed on the client’s computers (or even on my own, running directly from the executable), it fails with this message:

System.Invalidoperationexception: Could not locate the standard endpoint element referencing the 'Wstrf3.Iservicointegration' contract in the Servicemodel client configuration section. This may have occurred due to the lack of a configuration file for your application or because no endpoint element corresponding to this contract could be found in the client element.

I suppose something that is present during debugging is missing from the distribution, but I have no idea what. Any help will be very welcome.

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 thing would be to include these settings in the client’s machine configuration file. Probably this section exists inside the app.config file in your visual studio project and does not exist in the [executable].exe config file on the client’s machine.

Check more about these settings on microsoft documentation.

2

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

But next to that, I would like to alert you to another solution that I discovered, and which I will use because I would like to keep the distribution restricted to a single file: it is possible to deploy the configuration data directly in the code.

So I replaced it:

Dim myclient as New MyServiceReference.MyServiceClient

for

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

And voilà, it worked.

Thank you so much to everyone who tried to help me with this!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.