Silverlight 4 NetTcpBinding 编程配置

发布于 2024-09-02 20:47:48 字数 556 浏览 3 评论 0原文

我想以编程方式为 silverlight 4 客户端配置 NetTcpBinding。 (现在支持 NetTcpBinding)

以下是我用于为 Windows 窗体客户端执行此操作的代码:

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

对于 silverlight,我添加了对 System.ServiceModel.Extensions 和 System.ServiceModel.NetTcp 的引用,但这还不够:我不能够找到一个NetTcpBinding类。

这个类如果存在的话在哪里?是否存在等效语法?当使用配置文件时,silverlight 4 运行时必须以某种方式执行此操作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲鸠 2024-09-09 20:47:48

您可以使用自定义绑定代替 NetTcpBinding :下面的代码可以正常工作,但我不知道这是否是推荐的模式。

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文