2012-03-15 6 views
1

net.tcp接続プーリングを無効にする必要がある特定のシナリオがあります。私はそれが理想的な設定ではないことを認識していますが、私は特定の環境の問題を解決するために一時的に行う必要があります。WCF net.tcpバインディングの接続プールを無効にする

接続の再利用とプールを無効にするnet.tcpバインディング設定の例は誰でも提供できますか?

答えて

0

ここで私はそれをコードで行った方法です。

NetTcpBinding tbinding = new NetTcpBinding(SecurityMode.None, true); 

// set some stuff on the binding ... 
// ... 

BindingElementCollection bElementCol = tbinding.CreateBindingElements(); 

TcpTransportBindingElement transport = bElementCol.Find<TcpTransportBindingElement>(); 
transport.ConnectionPoolSettings.IdleTimeout = TimeSpan.Zero; 
transport.ConnectionPoolSettings.LeaseTimeout = TimeSpan.Zero; 
transport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = 0; 

CustomBinding customBinding = new CustomBinding(); 
customBinding.Elements.AddRange(bElementCol.ToArray()); 
customBinding.Name = "NetTcpBinding"; 
// use customBinding instead of tbinding 

ここではそれで私を助けたいくつかのリンクです:

How to set the leaseTimeout setting programmaticaly?

http://plainoldstan.blogspot.ca/2007/09/nettcpbinding-to-custombinding.html

http://msdn.microsoft.com/en-us/library/ms788984.aspx