问题描述
在测试我的wcf电子邮件服务时收到以下错误(仅当通过新电子邮件服务发送非常大的附件时才发生此错误-仅当附件的大小大于65536时明显):
已超过传入消息的最大消息大小配额(65536).要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性.
问题是,我已经将我的web.config中的MaxReceivedMessageSize属性设置为500000000的大值,我还使用以下代码在客户端本身以及服务的代码中设置了绑定,但没有更改:
Getting the following error when testing my wcf email service (this error happens *only* when sending a very large attachment through the new email service - obviously when the size of the attachment is larger than 65536):
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.
The question is, I am already setting the MaxReceivedMessageSize property in my web.config to a large value of 500000000, I also used the following code to set the binding in the code of the client itself as well as the service but no change:
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.CloseTimeout = new TimeSpan(00, 5, 00);
binding.OpenTimeout = new TimeSpan(00, 5, 00);
binding.ReceiveTimeout = new TimeSpan(00, 5, 00);
binding.SendTimeout = new TimeSpan(00, 5, 00);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.MaxReceivedMessageSize = 500000000; // int.MaxValue;
binding.MaxBufferSize = 500000000; // int.MaxValue;
要提及的一件事,在调用服务之前已经设置了上面的代码,是否需要在调用服务之前以某种方式将绑定"对象与消息相关联?
感谢您的前期帮助.
One thing to mention, having set the code above prior to calling the service, do I need to somehow associate the "binding" object with the message prior to calling the service?
Thanks for the help upfront.
推荐答案
这篇关于已超过传入消息的最大消息大小配额(65536)-C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!