C# WCF WinCE 解决方案 错误提示之:已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性

网上的解决方案:

出现这种错误,先去修改服务器端和客户端的MaxReceivedMessageSize值,如果还报错那么查看你的代码调用了是不是new了一个新的BasicHttpBinding对象,如果是new了新的那么你的webconfig根本就没有被调用,在new的时候要将 <binding name="DataSyncService" 中的name值作为参数传进去,或者是在代码里重新设置MaxReceivedMessageSize值

第一种

DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding("DataSyncService"), new EndpointAddress(new Uri(con)));

第二种

DataSyncServiceClient service = new DataSyncServiceClient(new BasicHttpBinding(), new EndpointAddress(new Uri(con)));

(service.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = int.MaxValue;
(service.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = int.MaxValue;
(service.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = int.MaxValue;

我自己项目中的问题:

//SMC.Binding binding = U8ServiceClient.CreateDefaultBinding();
                //string remoteAddress = U8ServiceClient.EndpointAddress.Uri.ToString();
                //EndpointAddress endpoint = new EndpointAddress(remoteAddress);
                //U8Client = new U8ServiceClient(binding, endpoint);
                //SessionID = U8Client.StartSession();

我们之前是用上面的这个方法来的:即使我在服务器端设置了:

 maxReceivedMessageSize="2147483647"

<dataContractSerializer maxItemsInObjectGraph="2147483647" />

也还是不起作用。

<?xml version="1.0"?>
<configuration><system.web><compilation debug="true" targetFramework="4.0"><assemblies><add assembly="Interop.U8Login, Version=1.14.0.0, Culture=neutral, PublicKeyToken=79A4E7AD54EEABCA"/></assemblies></compilation><customErrors mode="Off"/></system.web><appSettings><add key="defaultConnection" value="sqlCon"/><add key="DALAssemblyName" value="HZYA.DALSQLServer"/><add key="DALFactoryType" value="HZYA.DALSQLServer.DALMSSqlFactory"/><add key="SessionTimeOut" value="00:30:00"/></appSettings><connectionStrings><!--<add name="sqlCon" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=UFDATA_001_2010;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="System" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=UFSysTem;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="Barcode" connectionString="Data Source=CQY-PC\SQLEXPRESS2005;Initial Catalog=Barcode;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/>--><add name="sqlCon" connectionString="Data Source=wuyf\sql2005;Initial Catalog=UFDATA_001_2012;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="System" connectionString="Data Source=wuyf\sql2005;Initial Catalog=UFSysTem;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/><add name="Barcode" connectionString="Data Source=wuyf\sql2005;Initial Catalog=Barcode;User ID=sa;Password=sasa" providerName="System.Data.SqlClient"/></connectionStrings><system.serviceModel><services><service name="CommonService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="ICommonService" bindingConfiguration="LargeSizeWsHttpBinding"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="ICommonService" bindingConfiguration="LargeSizeBasicHttpBinding"/></service><service name="BarcodeService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="IBarcodeService"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IBarcodeService"/></service><service name="PrintService" behaviorConfiguration="ServiceBehavior"><endpoint address="" binding="wsHttpBinding" contract="IPrintService"/><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IPrintService"/></service><service name="LoginService" behaviorConfiguration="ServiceBehavior" ><!--<endpoint address="" binding="wsHttpBinding" contract="ILoginService" bindingConfiguration="NoneSecurity" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>--><endpoint address="basic" binding="basicHttpBinding" contract="ILoginService"/></service><service name="U8Service" behaviorConfiguration="ServiceBehavior" ><endpoint address="" binding="wsHttpBinding" contract="IU8Service" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IU8Service"/></service><!--<service name="U8Service" behaviorConfiguration="ServiceBehavior" ><endpoint address="" binding="wsHttpBinding" contract="ILoginService" bindingConfiguration="NoneSecurity" /><endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/><endpoint address="basic" binding="basicHttpBinding" contract="IU8Service"/></service>--></services><bindings><basicHttpBinding><binding name="LargeSizeBasicHttpBinding" maxBufferPoolSize="2147483647" receiveTimeout="00:00:10" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"><readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/></binding></basicHttpBinding><wsHttpBinding><binding name="LargeSizeWsHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"><readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/></binding><binding name="NoneSecurity" receiveTimeout="00:00:50" maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false"><readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/><reliableSession enabled="true"/><security mode="None"><message establishSecurityContext="true"/></security></binding></wsHttpBinding></bindings><behaviors><serviceBehaviors><behavior name="ServiceBehavior"><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="true"/><dataContractSerializer maxItemsInObjectGraph="2147483647" />
                </behavior><behavior name=""><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="false"/></behavior></serviceBehaviors></behaviors><serviceHostingEnvironment multipleSiteBindingsEnabled="true"/></system.serviceModel><system.webServer><directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate"/></system.webServer>
</configuration>

直到看到网上的这篇文章后,我修改了我的客户端 binding 类型为 basehttpbinding  后,才解决了。

代码如下:

                BasicHttpBinding binding = new BasicHttpBinding();binding.MaxReceivedMessageSize = int.MaxValue;binding.MaxBufferPoolSize = int.MaxValue;binding.MaxBufferSize = int.MaxValue;string remoteAddress = U8ServiceClient.EndpointAddress.Uri.ToString();EndpointAddress endpoint = new EndpointAddress(remoteAddress);U8Client = new U8ServiceClient(binding, endpoint);

posted on 2012-11-27 15:12 Alfa 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/wuyifu/archive/2012/11/27/2790824.html

C# WCF WinCE 解决方案 错误提示之:已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性...相关推荐

  1. 错误提示之:已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性...

    1.需要查看 配置文件中的 MaxReceivedSize属性的值,将其调大一些若并重新运行 .若以足够大,可不必调整. 2.在服务配置文件中添加如下信息或者直接在"工具"-&qu ...

  2. MaxReceivedMessageSize :已超过传入消息(65536)的最大消息大小配额

    做的windows应用程序(后台调用webservice),数据量大的时候,报错如下: System.ServiceModel.CommunicationException: 已超过传入消息(6553 ...

  3. pycharm代码编辑的时候无法显示错误提示_已解决

    今天打开自己的pycharm编译器,发现不能进行错误代码的提示,于是自己百度了一番,最终找到解决方法,这里分享给大家: 主要解决路线:pycharm–file–settings–editor–insp ...

  4. SQL SERVER错误:已超过了锁请求超时时段。 (Microsoft SQL Server,错误: 1222)

    在SSMS(Microsoft SQL Server Management Studio)里面,查看数据库对应的表的时候,会遇到"Lock Request time out period e ...

  5. Nature:全球掠夺性期刊已超过15500种

    2022年3月15日,Nature发表了Inter Academy Partnership组织(IAP)Tracey Elliott和Teresa M. de laPuente的来信,阐述了掠夺性期刊 ...

  6. java在线找错_平台配置及测试错误提示及解决方案

    平台配置错误提示及解决方案 开发者在点击提交服务的时候可能会遇到以下各种各样的问题,本文列举出部分平台会弹出的提示,以便解决提交出现的问题. 1. 请完成分发国家配置 原因:未选择分发国家或未保存 解 ...

  7. 用友文件服务器不存在,用友T6软件备份提示超时已过期,错误'53'文件不存在

    用友t6软件备份提示超时已过期,错误'53'文件不存在备份提示超时已过期,错误'53'文件不存在 备份提示超时已过期,错误'53'文件不存在 原因分析:后台表ua_log日志记录太多. 问题解答:清除 ...

  8. Linux下执行程序出现Text file busy错误提示时的解决方案

    Linux下执行程序出现Text file busy错误提示时的解决方案   Linux Text file busy(文本文件忙),发生此错误是因为当前文件已被占用,因此只要找出占用该文件的进程并杀 ...

  9. 创建或打开解决方案时提示“DotNetCore.1.0.1-SDK.1.0.0.Preview2-003131-x86“错误的解决方案

    创建或打开解决方案时提示"DotNetCore.1.0.1-SDK.1.0.0.Preview2-003131-x86"错误的解决方案 参考文章: (1)创建或打开解决方案时提示& ...

最新文章

  1. Java凝视Annotation
  2. 为什么matlab生成的exe文件只能在matlab中打开,在电脑的其他地方打不开?
  3. spark如何防止内存溢出_spark开发十大原则
  4. SAP云平台测试帐号如何进入Neo环境
  5. 如何在 ASP.Net Core 中使用 MiniProfiler
  6. Java实现Huffman哈夫曼树
  7. 【Python】利用pip下载Django超时失败的解决方法
  8. 谈一下关于CQRS架构如何实现高性能
  9. LINQ – 使用DataLoadOptions 提高LINQ to SQL 查询性能
  10. 雷军恭喜苏炳添全运会夺冠:你是小米精神的最好代言
  11. 蓝桥杯 ALGO-95 算法训练 2的次幂表示
  12. php批量数据提交mysql_php在mysql里批量插入数据(代码实例)
  13. sql:mysql:分析为什么like模糊查询效率低
  14. CAD2019的使用
  15. java使用freemarker模版下载成Excel文件
  16. Mybatis-Plus 基础知识点
  17. 区块链学习笔记23——ETH反思
  18. 服务器上的 Git - 生成 SSH 公钥
  19. TUF Notary
  20. 做XRD有什么用途?

热门文章

  1. php mysql 排名_mysql中如何实现排名
  2. 计算机活动感悟怎么写,计算机教学心得体会范文五篇.doc
  3. java socket调用接口_java调用websocket接口
  4. maxvalue mysql自动分区_创建mysql表分区的方法
  5. 提示tun虚拟网卡没有安装_Win10家庭版通过Hyper-V安装Centos7+Python3.7过程总结
  6. 一道简单却易混淆的高等数学求极限题目
  7. 9008刷机模式写入超时刷机帮_刷机时没有成功,然后变成黑砖,usb接口直接变成未知设备~希望大神救助!...
  8. python偶数个数_python基础
  9. 指数函数中x的取值范围_谨记!高考数学中容易出错的几个地方
  10. Linux单独编译设备树,迅为IMX6Q开发板-非设备树内核-单独编译内核驱动