olorin
olorin

Reputation: 2244

Silverlight 4 NetTcpBinding programmatic configuration

I'd like to configure a NetTcpBinding programatically for a silverlight 4 client. (NetTcpBinding is now supported)

Here is the code I use to do this for a Windows Forms client:

  EndpointAddress endpointAddress = new EndpointAddress(uri);
  NetTcpBinding netTcpBinding = new NetTcpBinding();
  MyServiceClient agentClient = new MyServiceClient(new InstanceContext(this), netTcpBinding, endpointAddress);

For silverlight I added references to System.ServiceModel.Extensions and System.ServiceModel.NetTcp, but this is not not enough : I'm not able to find a NetTcpBinding class.

Where is this class if it exists? Does an equivalent syntax exists? The silverlight 4 runtime must be doing this somehow when a configuration file is used.

Upvotes: 0

Views: 2051

Answers (1)

olorin
olorin

Reputation: 2244

You can use a custom binding in place of NetTcpBinding : the code below is working, but I don't know if this is the recommended pattern.

  BinaryMessageEncodingBindingElement messageEncoding = new BinaryMessageEncodingBindingElement();
  TcpTransportBindingElement tcpTransport = new TcpTransportBindingElement();
  CustomBinding binding = new CustomBinding(messageEncoding, tcpTransport);

Upvotes: 3

Related Questions