System.ServiceModel.CommunicationException HResult=0x80131501 Message=已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 Source=mscorlib StackTrace: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at QRCodeDemo.ServiceReferenceQr.IQRService.CreateQR(String codeString) at QRCodeDemo.ServiceReferenceQr.QRServiceClient.CreateQR(String codeString) in D:AnanSoftwareProjectDemoLearnQRCodeDemoQRCodeDemoConnected ServicesServiceReferenceQrReference.cs:line 50 at QRCodeDemo.Form1.Create(String codeString) in D:AnanSoftwareProjectDemoLearnQRCodeDemoQRCodeDemoForm1.cs:line 51 at QRCodeDemo.Form1.button3_Click(Object sender, EventArgs e) in D:AnanSoftwareProjectDemoLearnQRCodeDemoQRCodeDemoForm1.cs:line 130 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at QRCodeDemo.Program.Main() in D:AnanSoftwareProjectDemoLearnQRCodeDemoQRCodeDemoProgram.cs:line 19 内部异常 1: QuotaExceededException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。
在客户端的配置文件下,加入:
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IQRService" maxBufferSize="10485760" maxReceivedMessageSize="10485760"/> </basicHttpBinding> </bindings> <client> <endpoint address="http://119.23.200.19:8733/Design_Time_Addresses/QRServiceDemo/QRService/" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IQRService" contract="ServiceReferenceQr.IQRService" name="BasicHttpBinding_IQRService" /> </client> </system.serviceModel> </configuration>