我在vs2010中有一个包含一些项目的解决方案:
a wcf project a win form project a class library
我的类库引用了wcf服务。当我尝试使用此引用从winform app中的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" />
答案 0 :(得分:1)
有些事情会浮现在脑海中:
在配置文件中完全限定合同名称,即:
合同= “MikServiceShopInfo.IshopsService”
将类库的app.config中的<serviceModel>
部分复制到WinForm的配置文件中。类库不使用配置文件 - 它们使用引用它们的应用程序(网站,WinForm等)的配置文件。