【发布时间】:2015-03-26 11:18:45
【问题描述】:
我有一个在 IIS 8.5 上运行的 WCF 服务。我在 Windows 窗体项目和控制台应用程序项目中使用并测试了该服务,并且工作正常!但我无法使用 Visual Studio 2013 中的类库项目中的 Web 服务。
在 ServiceModel 客户端配置部分中找不到引用合同“bindSignalR.bindSinalRService”的默认端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
我查看了 Windows 窗体项目(有效)和类库项目的配置文件,但找不到区别。我做错了什么?
服务的web.Config是:
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="bindSignalRService.Web.bindSinalRService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="bindSignalRService.Web.bindSinalRService">
<endpoint address="" binding="customBinding" bindingConfiguration="bindSignalRService.Web.bindSinalRService.customBinding0"
contract="bindSignalRService.Web.bindSinalRService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
Windows 窗体中的 app.config(这个可以正常工作!)应用:
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_bindSinalRService">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://slascvm042:49904/bindSinalRService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_bindSinalRService"
contract="bindNewEventService.bindSinalRService" name="CustomBinding_bindSinalRService" />
</client>
</system.serviceModel>
</configuration>
但是当我尝试在类库应用程序中使用 WCF 服务时,我得到了错误: 在 ServiceModel 客户端配置部分中找不到引用合同“bindSignalR.bindSinalRService”的默认端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
【问题讨论】:
-
我得到的错误是粗体和中心的错误。
-
在什么情况下会出现该错误。我相信你的意思是你有一个例外。请发布完整的异常,包括堆栈跟踪和任何内部异常。出于故障排除目的,执行此操作的简单方法是捕获异常,然后发布
ex.ToString()的结果。 -
您在什么进程中托管类库?看起来托管您的库的应用程序的配置尚未使用上述配置进行更新。
-
System.InvalidOperationException:在 ServiceModel 客户端配置部分中找不到名为“Hola1”和合同“bindSignalRService.Web.bindSinalRService”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。
标签: wcf