4

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.

My web.config is as follows:

<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>
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
Taha
  • 1,086
  • 1
  • 10
  • 20

2 Answers2

6

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.

wherever you have service in the same web assembly or not, you have to include full TypeName of your service

EvgeniyK
  • 377
  • 3
  • 12
1

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. 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.

If you're using C#, the fully qualified name will be the complete namespace + '.' + 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. 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.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • Thanks for your response! The namespace part of name attribute was not correct. It is Prototype.ChatService not PrototypeSite.ChatService. But the problem still persist :( – Taha May 15 '11 at 17:15
  • +1 BasicHttpBinding is the binding which is used on the default endpoint – Barış Velioğlu Apr 01 '14 at 11:17