.net 已超出传入邮件的最大邮件大小配额 (65536)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7232355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The maximum message size quota for incoming messages (65536) has been exceeded
提问by DarthVader
I have the following configuration for a WCF service.
我有 WCF 服务的以下配置。
Even though I have increased the maxReceivedMessageSize , service still throws an error:
即使我增加了 maxReceivedMessageSize ,服务仍然抛出错误:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.`" exception.
已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。`" 异常。
How can this be solved?
如何解决这个问题?
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://localhost:22230/MyService.svc"
binding="basicHttpBinding"
bindingConfiguration="MyServiceBinding"
contract="IMyService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyServiceBinding"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="6553600"
maxBufferSize="6553600"
maxBufferPoolSize="524288"
transferMode="Buffered"
messageEncoding="Text"
textEncoding="utf-8"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel
回答by Peter
If this is the service config, you should look in your client config and match the maxReceivedMessageSize to the servers message size. The message is coming from your client.
如果这是服务配置,您应该查看您的客户端配置并将 maxReceivedMessageSize 与服务器消息大小匹配。该消息来自您的客户。
回答by Jacob Tabak
You need to increase the max message size in your client config. The default is 65536, doubling it may be sufficient for your needs.
您需要在客户端配置中增加最大消息大小。默认值为 65536,将其加倍可能足以满足您的需要。
If you are configuring your endpoints programmatically, the following code snippet may help:
如果您以编程方式配置端点,以下代码片段可能会有所帮助:
BasicHttpBinding binding = new BasicHttpBinding() { MaxReceivedMessageSize = 131072 };
Then, when instantiating your service client, pass in this binding object to the constructor. For example:
然后,在实例化您的服务客户端时,将此绑定对象传递给构造函数。例如:
MyServiceClient client = new MyServiceClient(binding, "http://www.mysite.com/MyService/");
回答by Osama Ibrahim
Be sure you copy the new App.config
确保复制新的 App.config

