views:

26

answers:

1

I have a wcf duplex service with work fine in silverlight. but the same service I want to consume in windows console application. My code as follow:

   var context = new InstanceContext(this);
   var address = new EndpointAddress("http://localhost:31881/PubSubService.svc");
   var binding = new CustomBinding(
                 new PollingDuplexBindingElement(),
                 new BinaryMessageEncodingBindingElement(),
                 new HttpTransportBindingElement());

    var client = new PubSubClient(context, binding, address);
    client.Publish("topic", "content");

App.config is "empty":

   <?xml version="1.0" encoding="utf-8" ?>
     <configuration>
   </configuration>

It give me an error:

Binding 'CustomBinding' doesn't support creating any channel types. This often indicates that the BindingElements in a CustomBinding have been stacked incorrectly or in the wrong order. A Transport is required at the bottom of the stack. The recommended order for BindingElements is: TransactionFlow, ReliableSession, Security, CompositeDuplex, OneWay, StreamSecurity, MessageEncoding, [...]

Could you help me? Thanks in advance.

A: 

The problem is that PollingDuplexHttpBinding and related binding element is available only in Silverlight API. So when you start new .NET project (Console application in your case) you can't use the same code, because .NET does not contain PollingDuplexBindingElement

Ladislav Mrnka