Silverlight的&放大器; WCF:最大邮件大小放大器、大小、邮件、最大

2023-09-04 00:44:40 作者:眼泪不听话

当我传递对象名单出来使用WCF的一切我的Silverlight应用程序运行正常,直到列表的增长过大。看来,当我超过80项我得到的错误: 远程服务器返回了意外的响应:(404)未找到

When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error: The remote server returned an unexpected response: (404) Not Found

我是presuming,这是因为名单已经成长过大的时候,名单有70项everyhing工作正常。但奇怪的错误消息,对吧?

I'm presuming that it's because the List has grown too big as when the List had 70 items everyhing works fine. Strange error message though, right?

在配置文件我改变maxBufferSize到它会接受,但我仍然不能有更多然后80个项目在我的名单上的最高值。

In the config file I change the maxBufferSize to the highest value that it will accept but still I can't have more then 80 items in my List.

我怎么能传递出大型物体,而无需拆分的对象了?

How can I pass out large objects without having to split the object up?

感谢肖恩,那么,究竟该怎么办呢? 这是我ServiceReferences.ClientConfig

Thanks Shawn, so where exactly do I do it? This is my ServiceReferences.ClientConfig

<configuration>
<system.serviceModel>
    <client>
      <!--"http://sy01911.fw.gsjbw.com/WcfService1/Service1.svc"-->
      <endpoint address="http://localhost/WcfService1/Service1.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService11"
            contract="SilverlightApplication1.ServiceReference1.IService1"
            name="BasicHttpBinding_IService1" />
    </client>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IService1" maxBufferSize="655360000"
                maxReceivedMessageSize="655360000">
                <security mode="None" />
            </binding>
            <binding name="BasicHttpBinding_IService11" maxBufferSize="655360000"
                maxReceivedMessageSize="655360000">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
</system.serviceModel>

这是你提到的服务器配置

and this is the server config that you mentioned

<services>
  <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior" >
    <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding" contract="WcfService1.IService1" >
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WcfService1.Service1Behavior">
      <!-- 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

推荐答案

如果您发送了大量的WCF项目,也确保maxItemsInObjectGraph是一个比较高的数字。

If you are sending out a large number of items from WCF, also make sure that maxItemsInObjectGraph is a relatively high number

<behaviors>
   <serviceBehaviors>
      <behavior name="YourBahvior">
         <dataContractSerializer maxItemsInObjectGraph="6553600"/>
      </behavior>
   </serviceBehaviors>
</behaviors>