解决WCF传输大数据量时出错
如不是很较真的应用,把缓冲区设大点就好了,再把序列化对象设大点
首先应将MaxReceivedMessageSize值设大,如:
<basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="2147483647"></binding>
</basicHttpBinding>
其次,应该将MaxItemsInObjectGraph值设大,如:
代码
<behavior name="bcf">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" /> <dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
以上为服务器端设置,服务器端和客户端均应设大,客户端设置如下:
代码
<behaviors>
<endpointBehaviors>
<behavior name="bhc">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors><basicHttpBinding>
<binding name="basicBinding" maxReceivedMessageSize="2147483647"></binding>
</basicHttpBinding>
至此基本已经OK,如果再有问题,可将maxBufferSize、receiveTimeout值设大即可。