日期:2014-05-17 浏览次数:20951 次
NetTcpBinding binding = new NetTcpBinding() { TransferMode = TransferMode.Buffered, MaxReceivedMessageSize = 2147483647 };
binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
binding.Security.Mode = SecurityMode.None;
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
binding.Name = "tcpTransport";
EndpointAddress address = new EndpointAddress(new Uri("net.tcp://" + uri),);
var channelFactory = new ChannelFactory<IServer>(binding, address);
channelFactory.Endpoint.Behaviors.Add(new ContextHeaderBehavior());
var channel = channelFactory.CreateChannel();