【发布时间】:2014-07-31 08:57:46
【问题描述】:
我正在开发一个应用程序,如果客户端上传任何文档(任何扩展名),它应该同步到服务器。为此,我开发了具有 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 属性来增加此配额
提前致谢
【问题讨论】:
-
到处都是。 Just an example。此外,也许您考虑重新设计并分块发送文件,而不是一次全部发送。或者甚至可能为此使用专用协议 (FTP)。
标签: c# wcf windows-services