【问题标题】:When does WCF NetTcpBinding need full trust on the client?WCF NetTcpBinding 何时需要完全信任客户端?
【发布时间】:2011-01-19 11:09:14
【问题描述】:

我正在使用 WCF 与多个服务器进行通信。

对于我的本地服务器 netTcpBinding 工作正常,没有问题。

但是当我尝试使用app.config 中的以下 netTcpBinding 连接到我的远程服务器 (Azure) 时,这将导致应用程序在初始化时崩溃,因为在没有完全信任的情况下无法创建 netTcpBinding。

app.config 文件中的此绑定,

<bindings>
  <netTcpBinding>
    <binding name="NetTcpBinding_IService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
      hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
      maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None" protectionLevel="EncryptAndSign" />
        <message clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

会导致这个错误:

为“system.serviceModel/bindings”创建配置节处理程序时出错:该程序集不允许部分受信任的调用方。 (K:\Somepath\Testing.exe.Config 第 6 行)

奇怪的是:在app.config 文件中,我得到了连接到其他 netTcpBindings 的客户端端点(没有在绑定部分明确声明它们)。

为什么这些通用的 netTcpBindings 可以在部分信任下工作,而我上面展示的那个却不行?

或者我只是被这个错误信息弄糊涂了,问题不在于完全信任?

更新:如果我删除 部分,这些东西将毫无问题地运行。所以我可以在部分信任的情况下使用 netTcpBinding,但我不能修改参数?很遗憾,因为我想对我的通信进行某种形式的加密。

【问题讨论】:

    标签: wcf nettcpbinding


    【解决方案1】:

    一般而言,部分信任环境不支持 NetTcpBinding。

    虽然基本通信工作正常(正如您在其他环境中看到的那样),但 TransportSecurity 和 ReliableMessaging 等功能(您在示例配置中拥有)明确地是 not supported on partial trust(这很糟糕,很长时间)。

    【讨论】:

    • 有趣的是:默认的 nettcpbinding 确实在部分信任下对我有用。只是当我避免配置文件中的 部分时它才起作用。如果我尝试指定有关绑定的任何内容,nettcpbinding 将在部分信任中失败。
    猜你喜欢
    • 2012-10-24
    • 2010-12-23
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多