简体   繁体   中英

Webservice consuming works only when debugging under VS IDE

My WinForms VB.NET Application consumes a webservice to perform some queries. When running in debug mode under Visual Studio IDE, it works smoothly, but once deployed in client workstations (or even in my own workstation), it crashes with this message:

System.InvalidOperationException: Could not find default endpoint element that references contract 'MyServiceReference.IMyService' 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 guess something that is present when debugging is missing in deployment, but I can't figure out what.

Good fellow S.Dav commented above to alert that I should deploy app.config together with my .exe file to solve this issue. He is correct and if it was an answer, I'd accept it.

Besides, I found that I can hardcode service config data and it will work also.

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 voilà , it worked.

Many thanks for all those who tried and helped with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM