我正在开发一个应用程序,如果客户端上传任何文档(任何扩展名),它应该同步到服务器。为此我开发了具有wcf引用的Windows服务。 Windows服务在后台运行特定的时间间隔,并检查文件是否存在于服务器上,如果没有传输文件。我的问题是大小以字节为单位的小文件从客户端传输到服务器但是大小超过16kb的文件失败转移。即使我尝试在配置文件中将maxarrayLength增加到2GB。但它没有转移。
这是web.config文件中的代码
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISyncUpService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WebSetup/Services/SyncUpService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISyncUpService"
contract="SyncUpService.ISyncUpService" name="BasicHttpBinding_ISyncUpService" />
</client>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
我收到以下异常
反序列化System.IO.MemoryStream类型的对象时出错。读取XML数据时已超出最大数组长度配额(16384)。通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxArrayLength属性,可以增加此配额
提前致谢
答案 0 :(得分:0)
您可以尝试在服务和客户端配置文件上设置更大的MaxArrayLength属性。