我想能夠發送大量的數據到我的WCF service
,我發送的是List<byte[]>
,客戶端收到並且當前我的應用程序得到一個錯誤,套接字中止。WCF和大量的數據
,所以我發現部份螺紋:http://geekswithblogs.net/tmurphy/archive/2011/08/15/sending-large-arrays-with-wcf.aspx
這是我的連接是如何estanlished:
string urlService = "net.tcp://localhost:8000/myApp";
ServiceHost host = new ServiceHost(typeof(pp.classes.service1));
host.Opening += new EventHandler(host_Opening);
host.Opened += new EventHandler(host_Opened);
host.Closing += new EventHandler(host_Closing);
host.Closed += new EventHandler(host_Closed);
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial
pp.classes.service1 ser = new pp.classes.service1();
host.AddServiceEndpoint(typeof(pp.classes.IService1), tcpBinding, urlService);
ServiceMetadataBehavior metadataBehavior;
metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metadataBehavior == null)
{
// Create the proxy object that is generated via the svcutil.exe tool
metadataBehavior = new ServiceMetadataBehavior();
metadataBehavior.HttpGetUrl = new Uri("http://localhost:8001/myApp");
metadataBehavior.HttpGetEnabled = true;
metadataBehavior.ToString();
host.Description.Behaviors.Add(metadataBehavior);
string urlMeta = metadataBehavior.HttpGetUrl.ToString();
}
host.Open();
我試圖找到maxReceivedMessageSize
,maxStringContentLength
和maxArrayLength
性質,但我發現只有maxReceivedMessageSize
(我工作不app.config文件)
我沒有一個,我沖水WCF服務在我的WinForms GUI – user3271698
可能重複的:http://stackoverflow.com/questions/969479/modify-endpoint-readerquotas-programatically所有我的 – ilansch
第一愛評論* < - 非常關鍵*沒有任何進一步解釋爲什麼。那很棒。你也應該將WCF配置添加到你的'app.config'中,這使配置變得更容易(是的,即使你自己託管服務,你也可以這麼做)。第三,你可能會想要使用流式服務,它允許你通過流傳輸大量的數據。這個問題似乎總結得很好:http://stackoverflow.com/questions/14479885/wcf-streaming-large-data-500mb-1gb-on-a-self-hosted-service –