在C#.net中使用WCF服务时出错 [英] Error in Consuming WCF service in c# .net

查看:60
本文介绍了在C#.net中使用WCF服务时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im试图从客户端应用程序使用wcf服务. WCF服务托管在Web中.将服务引用添加到项目后,将生成所有代理.

当我尝试访问代理类方法时,出现以下错误:

无法加载合同"XService.XServicePortType"的端点配置部分,因为找到了该合同的多个端点配置.请按名称指示首选的端点配置部分.

在app.config中,我删除了自定义绑定端点.我只有一个http端点.

请提出建议.

预先感谢.

im trying to consume a wcf service from a client application. Thw WCF services is hosted in web. After i add the service reference to the project, all the proxy gets generated.

when im tryin to access the proxy class methods., im gettin gthe below error:

An endpoint configuration section for contract ''XService.XServicePortType'' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

In app.config, i removed custom binding end points. I have just one http end point.

please suggest.

Thanks in advance.

推荐答案

好吧,我认为错误消息准确地描述了这种情况.该服务在多个端点上公开合同.
基本上,在创建新的客户端对象时,请使用重载的构造函数(具有端点名称的构造函数).您可以从app.config中获取所需的名称.
Well, I think that the error message accurately describes the situation. The service exposes the contract on several endpoints.
Basically when creating the new client object, use the overloaded constructor (the one with the endpoint name). You fetch the name you want from the app.config.


尝试跟随
YourServiceClient service_obj = new  YourServiceClient("EndPointName");


这篇关于在C#.net中使用WCF服务时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆