C# WebService无法加载协定为“ServiceReference1.xxxxxx”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分

winform中添加了服务引用webservice后,在代码中调用创建服务引用提供的类时,提示:无法加载协定为“ServiceReference1.xxxxxx”的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。原因请在解决方案资源管理器界面找到App.config文件打开。查看是否bindings项有多个,确实有多个话,删掉没有使用的binding相关的信息,只保留一个,或者后期手动代码指定选择哪一个。

例如: 

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="AutoStopLineSoap" />
            </basicHttpBinding>
            <!--<customBinding>
                <binding name="AutoStopLineSoap12">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpTransport />
                </binding>
            </customBinding>-->
        </bindings>
        <client>
            <endpoint address="http://10.100.160.37:111/AutoStopLine.asmx"
                binding="basicHttpBinding" bindingConfiguration="AutoStopLineSoap"
                contract="ServiceReference1.AutoStopLineSoap" name="AutoStopLineSoap" />
            <!--<endpoint address="http://10.100.160.37:111/AutoStopLine.asmx"
                binding="customBinding" bindingConfiguration="AutoStopLineSoap12"
                contract="ServiceReference1.AutoStopLineSoap" name="AutoStopLineSoap12" />-->
        </client>
    </system.serviceModel>

如上,我的bindings参数有两个,第二个AutoStopLineSoap12被我禁用了,包括和AutoStopLineSoap12相关的Client.

禁用之后,这个问题就没有了。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值