3

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

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

但是,当我尝试使用以下 netTcpBinding in 连接到我的远程服务器(Azure)时app.config,这将使应用程序在初始化时崩溃,因为如果没有完全信任就无法创建 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 在部分信任的情况下工作,而我上面展示的却没有?

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

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

4

1 回答 1

2

部分信任环境通常不支持 NetTcpBinding。

虽然基本通信工作正常(正如您在其他环境中看到的那样),但部分信任明确不支持TransportSecurity 和 ReliableMessaging 等功能(您在示例配置中拥有) (这很糟糕,很长时间)。

于 2011-01-26T07:40:11.413 回答