The following method (in which I hopefully did not make any mistakes while dramatically simplifying it for this post) is working properly and set up using the Streamed trans
Here is another way to do it without having to deal with Reflection. Just wrap NetTcpBinding into CustomBinding.
var binding = new CustomBinding(new NetTcpBinding
{
MaxReceivedMessageSize = 2147483647,
MaxBufferSize = 2147483647,
MaxBufferPoolSize = 2147483647,
ReceiveTimeout = new TimeSpan(4, 1, 0),
OpenTimeout = new TimeSpan(4, 1, 0),
SendTimeout = new TimeSpan(4, 1, 0),
CloseTimeout = new TimeSpan(4, 1, 0),
ReaderQuotas = XmlDictionaryReaderQuotas.Max,
Security =
{
Mode = SecurityMode.None,
Transport = {ClientCredentialType = TcpClientCredentialType.None}
},
TransferMode = TransferMode.Streamed,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
});
binding.Elements.Find().ConnectionBufferSize = 665600;