Pregunta

I have a winForms application running on a server and I access it from another application via a Service which is running over a ServiceHost.

The problem is, when the data which the client wants to get from the ServiceHost is to big I get a exception like:

Error while receiving, the reason could be not using a http-protocol.

How can I solve this? Would this be a web application I simply would increase the maxRequestLength/executionTimeout in the web.config. but there is no web.config in a winforms project.

EDIT: here is some code:

Service s = new Service(this.foo);
ServiceHost host = new ServiceHost(s, baseAddress);
host.AddServiceEndpoint(typeof(IService), new BasicHttpBinding(), "");
host.Open();
¿Fue útil?

Solución

When creating the binding (in your example BasicHttpBinding) just set its MaxReceivedMessageSize (http://msdn.microsoft.com/de-de/library/system.servicemodel.httpbindingbase.maxreceivedmessagesize.aspx) to the value appropriate for your scenario.

    var binding = new BasicHttpBinding { MaxReceivedMessageSize = 20000; };
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top