我想從WCF服務獲取一些數據,但是當我嘗試獲取綁定時出現錯誤; 「在配置元素集合」 「中找不到與密鑰」GetWorksOrdersListBinding「匹配的元素。第二行顯示異常,第一行是OK;C#Windows服務無法獲取WCF綁定
var endpointAddress = this.GetEndpointAddress("GetWorksOrdersList");
var binding = this.GetBinding("GetWorksOrdersListBinding");
被調用的方法是;
public EndpointAddress GetEndpointAddress(string method)
{
return new EndpointAddress(this.ServiceUrlRoot + method);
}
public BasicHttpsBinding GetBinding(string binding)
{
return new BasicHttpsBinding(binding);
}
該App.Config文件包含以下內容;
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GetWorksOrdersDetailBinding" />
<binding name="GetWorksOrdersListBinding" />
<binding name="UpdWorksOrdersCompBinding" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxx-test.xxxxxxxxxxxx.co.uk/communication/GetWorksOrdersDetail"
binding="basicHttpBinding" bindingConfiguration="GetWorksOrdersDetailBinding"
contract="GetWorksOrdersDetailPort" name="GetWorksOrdersDetailPort" />
<endpoint address="http://xxxx-test.xxxxxxxxxxx.co.uk/communication/GetWorksOrdersList"
binding="basicHttpBinding" bindingConfiguration="GetWorksOrdersListBinding"
contract="GetWorksOrdersListPort" name="GetWorksOrdersListPort" />
<endpoint address="http://xxxx-test.xxxxxxxxxxx.co.uk/communication/UpdWorksOrdersComp"
binding="basicHttpBinding" bindingConfiguration="UpdWorksOrdersCompBinding"
contract="UpdWorksOrdersCompPort" name="UpdWorksOrdersCompPort" />
</client>
</system.serviceModel>
你確定'GetWorksOrdersListBinding'出現在WCF服務中(我的意思是名稱不匹配可能存在)?你的App.Config看起來很好。 – 2014-11-21 11:02:40