2012-03-15 90 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

相關問題