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.
禁用之后,这个问题就没有了。