2012-07-12 15 views
1

的winform我在VS2010的解決方案,其中包含一些項目:使用WCF在通過類庫

 
a wcf project 
a win form project 
a class library 

我的類庫具有參考的WCF服務。當我嘗試使用此引用的檢索winform應用程序從WCF數據提出了這個錯誤:

Could not find default endpoint element that references contract 'MikServiceShopInfo.IshopsService' 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.

我改變類庫的app.config到這一點:

<endpoint address="http://localhost:8855/LaptopsInfoService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_ILaptopsInfoService" 
      contract="ILaptopsInfoService" 
      name="BasicHttpBinding_ILaptopsInfoService" /> 
<endpoint address="http://localhost:8855/shopsService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IshopsService" 
      contract="IshopsService" 
      name="BasicHttpBinding_IshopsService" /> 

回答

1

有幾件事情浮現在腦海中:

  1. 設施資格在配置文件中的合同名稱,即:

    合同=「MikServiceShopInfo.IshopsService」

  2. 複製從您的app.config的類庫,爲您的WinForm的配置文件中的<serviceModel>部分。類庫不使用配置文件 - 它們使用應用程序的配置文件(網站,WinForm等)引用它們。

+0

默認情況下存在完全合格的合同名稱。我改變它來解決我的問題。我已經將複製到了我的winapp項目中,但問題仍然存在。 – 2012-07-13 10:02:01