2011-01-19 37 views
3

我正在使用WCF與多個服務器進行通信。WCF NetTcpBinding何時需要完全信任客戶端?

對於我的本地服務器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> 

這將導致此錯誤:

An error occurred creating the configuration section handler for "system.serviceModel/bindings": That assembly does not allow partially trusted callers. (K:\Somepath\Testing.exe.Config line 6)

奇怪的事情:在app.config文件我連接到其他netTcpBindings客戶端的端點(不在綁定部分中聲明它們)。

爲什麼這些通用netTcpBindings在部分信任下工作,但我上面顯示的不是?

或者我只是被這個錯誤信息所困惑,而問題不是完全信任?

更新:如果我刪除了<綁定>部分,那麼這些東西將毫無問題地運行。所以我被允許在部分信任中使用netTcpBinding,但我不允許修改參數?這是一個遺憾,因爲我想對我的通信進行某種形式的加密。

回答

2

NetTcpBinding通常在部分信任環境中不受支持。

雖然基本的通信正常工作(如你在其他環境中看到的),像TransportSecurity和ReliableMessaging的(你有你的樣品配置)的特點是明確not supported on partial trust(它吮吸,大的時間)。

+0

有趣的是:默認的nettcpbinding * does *在部分信任中爲我工作。這正是我在配置文件中避免使用部件的原因。如果我嘗試指定綁定的任何內容,則nettcpbinding在部分信任中失敗。 – Sam 2011-01-27 13:10:08