注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

回忆之旅

我很向往山村的农庄生活,他们的热情,让我无法抗拒! 51EOO.COM

 
 
 

日志

 
 

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

2013-12-22 18:19:43|  分类: 技术分享 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

网上的解决方案:

 

出现这种错误,先去修改服务器端和客户端的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>



本人:
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="LargeSize"  maxBufferSize="2147483647" maxBufferPoolSize="21474836471" maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="CX.Web.ScanWebImage.SacnWebImagesBehavior" >
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <services>
            <service behaviorConfiguration="CX.Web.ScanWebImage.SacnWebImagesBehavior" name="CX.Web.ScanWebImage.SacnWebImages">
                <endpoint address="" binding="basicHttpBinding" contract="CX.Web.ScanWebImage.ISacnWebImages" bindingConfiguration="LargeSize"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
    </system.serviceModel>
  评论这张
 
阅读(38)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017