【问题标题】:I get For TransferMode.Buffered, MaxReceivedMessageSize and MaxBufferSize must be the same value我得到对于 TransferMode.Buffered,MaxReceivedMessageSize 和 MaxBufferSize 必须是相同的值
【发布时间】:2012-04-02 14:00:45
【问题描述】:

这是我在 Windows Azure 服务项目上的 Web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
  </configSections>
  <!--  To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section.
        To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
        To avoid performance degradation, remember to disable tracing on production deployments.
  <system.diagnostics>     
    <sharedListeners>
      <add name="AzureLocalStorage" type="NutriLeaf.Services.AzureLocalStorageTraceListener, NutriLeaf.Services"/>
    </sharedListeners>
    <sources>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
    </sources> 
   </system.diagnostics> -->

  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>




  <system.serviceModel>


    <bindings>
      <basicHttpBinding>
        <binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
    <connectionStrings>
        <remove name="LocalSqlServer" />
        <add connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

这是我在 Windows Phone 7 客户端上遇到的异常

对于 TransferMode.Buffered,MaxReceivedMessageSize 和 MaxBufferSize 必须是相同的值。 参数名称:绑定元素

我什至尝试设置 TransferMode="Streamed" 但这没有帮助,我得到了同样的异常。你能帮帮我吗?我是否缺少 Web.config 文件的部分内容?

请帮忙!

【问题讨论】:

  • 客户端的 MaxReceivedMessageSize 和 MaxBufferSize 的值是多少?可能是您的手机(客户端)上的设置不匹配,而不是服务。
  • 你能发布完整的Exception.ToString() 值吗?
  • 我遇到了同样的问题,从客户端完全删除了 WCF 服务引用并再次添加它。问题已解决。希望这会有所帮助。

标签: wcf iis azure windows-phone-7.1


【解决方案1】:

问题可能是在客户端产生的。检查 WP7 应用上的 ServiceReferences.ClientConfig 文件并检查绑定。

它们应该是这样的:

<bindings> 
  <basicHttpBinding> 
    <binding name="{YOUR SERVICE NAME HERE" 
             maxBufferSize="2147483647" 
             maxReceivedMessageSize="2147483647"> 
  <security mode="None" /> 
</binding> 

您需要确保maxBufferSizemaxReceivedMessageSize 与服务器配置中的值相同。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。我不知道这是否是 WP7 Silverlight 运行时中的错误,但是如果绑定是在代码中而不是在 ServiceReferences.ClientConfig 中定义的,它可以正常工作。像这样的:

    var client = new MyServiceClient(
        new BasicHttpBinding( BasicHttpSecurityMode.None )
        {
            MaxReceivedMessageSize = 2147483647,
            MaxBufferSize = 2147483647
        },
        new EndpointAddress( yourAddress ) );
    

    我还不知道这是什么原因。

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 1970-01-01
      • 2023-03-29
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 2017-09-20
      • 1970-01-01
      • 2019-09-17
      相关资源
      最近更新 更多