欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

WCF 传输大数据量时的异常解决

程序员文章站 2022-07-13 15:38:24
...
参考:http://consultingblogs.emc.com/merrickchaffer/archive/2007/09/19/WCF-System.Net.WebException_3A00_-The-underlying-connection-was-closed_3A00_-The-connection-was-closed-unexpectedly.aspx

主要是在服务端和客户端增加序列化的配置:

  <dataContractSerializer maxItemsInObjectGraph="2147483646" /> 

服务端: 
<service name="XXX"  beaviorConfiguration="ProductMetadataServiceBehaviors">  

 <behaviors>
          <serviceBehaviors>
            <behavior name="ProductMetadataServiceBehaviors" >
              <!-- Add the following element to your service behavior configuration. -->
              <serviceMetadata httpGetEnabled="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
 客户端:
 <client>
这个endpoint里
的 maxBufferSize="。。。" maxBufferPoolSize="。。。" maxReceivedMessageSize="。。。" 要设置的大一些。。。
    <endpoint XXX....
                      behaviorConfiguration="SerializerBehaviour"/>
        </client>

      <behaviors>
        <endpointBehaviors>
          <behavior name="SerializerBehaviour">
            <dataContractSerializer maxItemsInObjectGraph="2147483646" />
          </behavior>
        </endpointBehaviors>

      </behaviors>  
 

转载于:https://www.cnblogs.com/v-jing/archive/2011/06/10/2077556.html