C# 大型WCF结果发送到Silverlight应用程序
我目前有一个Silverlight应用程序调用WCF服务,该服务返回大约7000个对象。我们可以让它返回大约6500个对象,但返回整个集合失败。它还允许我们从DTO中删除属性,但将其添加回会导致失败 因此,我们的客户端配置为:C# 大型WCF结果发送到Silverlight应用程序,c#,wcf,silverlight,C#,Wcf,Silverlight,我目前有一个Silverlight应用程序调用WCF服务,该服务返回大约7000个对象。我们可以让它返回大约6500个对象,但返回整个集合失败。它还允许我们从DTO中删除属性,但将其添加回会导致失败 因此,我们的客户端配置为: <basicHttpBinding> <binding name="EchoWCFBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<basicHttpBinding>
<binding name="EchoWCFBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"></binding>
</basicHttpBinding>
<basicHttpBinding>
<binding name="simpleHttp" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
因此,我们的服务器配置为:
<basicHttpBinding>
<binding name="EchoWCFBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"></binding>
</basicHttpBinding>
<basicHttpBinding>
<binding name="simpleHttp" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
我们正在使用ChannelFactory连接到服务,如果我们在客户端上增加maxReceivedMessageSize,它会在构造时抛出一个异常,表示它必须是int。试试这个
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" >
<readerQuotas maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
我用代码解决了这个问题,它实际上提供了更好的用户体验。我将列表拆分为可管理的块,并通过单独的客户端请求通过网络发送它们。有了这个,我可以提供一个进度条。WCF服务设置非常糟糕,我因为类似的错误损失了好几天。如果您没有得到完整的异常信息(即,您得到的是可怕的“NotFound”错误),您应该启用日志记录,然后您将获得更多信息。请参阅SO文章[获取更多信息的答案。此博客:[还有关于日志记录的有用信息,我用来查看我的异常内部。