开发者

Silverlight 4 NetTcpBinding programmatic configuration

开发者 https://www.devze.com 2023-01-01 10:43 出处:网络
I\'d like to configure a NetTcpBinding programatically for a silverlight 4 client. (NetTcpBinding is now supported)

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开发者_如何学JAVA syntax exists? The silverlight 4 runtime must be doing this somehow when a configuration file is used.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号