【问题标题】:Wcf Use in winform via class librarywcf 通过类库在winform中使用
【发布时间】:2012-07-13 13:51:33
【问题描述】:

我在 vs2010 中有一个包含一些项目的解决方案:

一个 wcf 项目 一个赢的形式项目 一个类库

我的类库有 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" />

【问题讨论】:

    标签: wcf .net-4.0 wcf-binding


    【解决方案1】:

    想到几件事:

    1. 在配置文件中完全限定合约名称,即:

      contract="MikServiceShopInfo.IshopsService"

    2. 将类库的 app.config 中的 &lt;serviceModel&gt; 部分复制到 WinForm 的配置文件中。类库不使用配置文件 - 它们使用引用它们的应用程序(网站、WinForm 等)的配置文件。

    【讨论】:

    • 默认存在完全限定合约名称。我改变它来解决我的问题。我已将 复制到我的 winapp 项目中,但问题仍然存在。
    猜你喜欢
    • 2021-09-26
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多