简体   繁体   English

合同需要Duplex,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它

[英]Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it

I have followed this tutorial for building my chat application. 我已经按照本教程构建了聊天应用程序。 When I try to add reference of my service I get the following error: 当我尝试添加我的服务的引用时,我收到以下错误:

Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it. 合同需要Duplex,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它。

My web.config is as follows: 我的web.config如下:

<extensions>
  <bindingExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </bindingExtensions>
</extensions>

<bindings>      
  <pollingDuplex>
    <binding name="chatPollingDuplex" duplexMode="MultipleMessagesPerPoll"/>
  </pollingDuplex>
</bindings>    

<services>      
  <service name="PrototypeSite.ChatService">        
    <endpoint address="" binding="pollingDuplex" bindingConfiguration="chatPollingDuplex" contract="PrototypeSite.ChatService" />
    <endpoint address="mex" binding="wsDualHttpBinding" contract="IMetadataExchange"/>
  </service>      
</services>

When I'd got this error, It made a lot of pain for me, but the solution was quite simple - double check service name in your web.config. 当我遇到这个错误时,它给我带来了很多痛苦,但解决方案很简单 - 在web.config中仔细检查服务名称。

wherever you have service in the same web assembly or not, you have to include full TypeName of your service 无论您是否在同一Web组件中提供服务,您都必须包含服务的完整TypeName

BasicHttpBinding is the binding which is used on the default endpoint - the one which is created when no element can be found which matches the service name. BasicHttpBinding是在默认端点上使用的绑定 - 当找不到与服务名称匹配的元素时创建的绑定。 The "name" attribute in the element must match the fully-qualified name of the service class, which I guess isn't the case in your scenario. 元素中的“name”属性必须与服务类的完全限定名称匹配,我认为在您的方案中不是这种情况。

If you're using C#, the fully qualified name will be the complete namespace + '.' 如果您使用的是C#,则完全限定名称将是完整的名称空间+'。' + the class name. +班级名称。 If you're using VB, it's possible that the "root namespace" property of the project is prepended to the namespace name. 如果您使用的是VB,则项目的“根命名空间”属性可能会添加到命名空间名称之前。 The sure way to find out the name to use is to use a tool such as reflector or ildasm and open the DLL which contains your service class. 找出要使用的名称的可靠方法是使用反射器或ildasm等工具,并打开包含服务类的DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM