14

WCF 呼び出しで次のエラーが表示されます。

オブジェクト グラフでシリアライズまたはデシリアライズできるアイテムの最大数は '65536' です

私は大量のフォーラム投稿を読みましたが、その多くは app.config と web.config を変更して新しい動作を指定し、より大きなオブジェクト グラフを許可することについて言及しています。私はそれを行いました、そしてこれは私がそれらのファイルに持っているものです:

WPF プロジェクトの App.Config:

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="">
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
    </behavior>

  </endpointBehaviors>

</behaviors>

<services>
  <service name="digiPM.Shell.LogOutPMSEMRService.PMSEMRLogOutService">
    <!--<endpoint address="" binding="basicHttpBinding" contract="digiPM.Shell.LogOutPMSEMRService.IPMSEMRLogOutService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/Design_Time_Addresses/digiPM.Shell.LogOutPMSEMRService/PMSEMRLogOutService/" />
      </baseAddresses>
    </host>-->
    <endpoint address="" binding="netTcpBinding" name="NetTcpBindingEndpoint" contract="digiPM.Shell.LogOutPMSEMRService.IPMSEMRLogOutService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="MexTcpBidingEndpoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8732/Design_Time_Addresses/digiPM.Shell.LogOutPMSEMRService/PMSEMRLogOutService/" />
      </baseAddresses>
    </host>
  </service>
</services>

<!--binding info - removed this for the sake of readability for this post -->

サービス プロジェクトの web.config:

<system.serviceModel>

<bindings>
  <wsHttpBinding>
      <binding name="WSHttpBinding_Services" closeTimeout="01:10:00" openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00" bypassProxyOnLocal="false" 
               transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" 
               messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="4096" maxStringContentLength="2147483647" maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
          <reliableSession ordered="true" inactivityTimeout="01:10:00" enabled="false" />

          <security mode="None">

          </security>
      </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="digiPM.Service.Behavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>

  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="customObjectQuota">
      <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="digiPM.Service.Behavior"
    name="digiPM.Service.AddressCrudService">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Services"
                name="AddressCrudServiceEndPoint" bindingNamespace="urn:Dawliasoft.Sculpture"  contract="digiPM.Services.Contracts.IAddressCrudService" behaviorConfiguration="customObjectQuota" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"  behaviorConfiguration="customObjectQuota" />
  </service>

 <!--<more services defined with same configuration as above..>-->

  </services>


</system.serviceModel>

ただし、これは役に立ちませんでした。APP.CONFIG で参照されているサービスは、私が問題を抱えているサービスではないことに注意してください。

私も次のことを試しました:

  • これらの属性をサービス実装に追加しました: [DataContract(IsReference=true)]、[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any、MaxItemsInObjectGraph = 2147483646)]

  • MaximumObjectsInGraph と IsReference の動作を設定するカスタム DataContractSerializerOperationBehavior クラスを作成しました。また、これをサービス実装に適用するカスタム属性も追加されました。混乱を避けるために、コードは投稿しませんでしたが、誰かが有益だと思う場合は追加できます。

考え?アイデア?ここからどこへ行けばいいですか?

前もって感謝します!

4

5 に答える 5

16

以下の値を設定すると、問題が解決しました。

クライアント構成:

<system.serviceModel>
<bindings>
<basicHttpBinding>
  <binding name="BasicHttpBinding_IManagementService" closeTimeout="00:01:00"
    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
    <readerQuotas maxDepth="128" maxStringContentLength="2147483647"
      maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None"
        realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
  </binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://XXXX/ManagementService.svc"
  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IManagementService"
  contract="ManagementServiceReference.IManagementService"
  name="BasicHttpBinding_IManagementService" behaviorConfiguration="ManagementServiceBehaviour"/>
</client>
<behaviors>
<endpointBehaviors>
  <behavior name="ManagementServiceBehaviour">
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
  </behavior>
</endpointBehaviors>
</behaviors>

サーバー構成:

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
  <behavior name="ManagementServiceBehaviour">
    <serviceDebug includeExceptionDetailInFaults="true" />
    <serviceMetadata httpGetEnabled="true" />
    <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
  </behavior>
  <behavior name="">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="false" />
  </behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
  <binding name="BasicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
    <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  </binding>
</basicHttpBinding>
</bindings>

<services>
<service behaviorConfiguration="ManagementServiceBehaviour" name="BusinessLogic.Facade.EntityFacade.Services.ManagementService">
  <endpoint binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="BusinessLogic.Facade.EntityFacade.Contracts.IManagementService">
    <identity>
      <dns value="" />
    </identity>
  </endpoint>
</service>
</services>
</system.serviceModel>
于 2011-12-28T13:17:18.830 に答える
6

バッファと最大受信メッセージサイズも上げてみましたか?

maxBufferSize="6553600" maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
于 2011-09-19T20:26:28.723 に答える
4

あなたの WPF 設定ファイルが正しくないことに気付きました。そのため、有効な WCF 構成を想定していたため、すべてのコメントを削除しました。WPF 構成ファイルが正しくありません...サービスの代わりに「クライアント」と言う必要があります... Visual Studio で「サービス参照の追加」を使用していますか? もしそうなら、それはあなたのために正しい設定ファイルを作成したはずです。

それ以外の場合は、 MSDNを参照して、WPF プロジェクトのクライアント構成ファイルの正しい形式を確認してください。

于 2011-09-19T20:34:34.823 に答える
1

「dataContractSerializer」要素に注意してください。私の場合、この要素を親要素「動作」の最初の項目として配置するまで、言及されたエラーが発生しました。少なくともクライアント側では。

于 2013-08-21T12:52:26.283 に答える
0

サイズが 65536 を超える一般的なリストまたは配列を返しています。クエリで select top 60000 を使用するか、60k を超える要素を追加しないと、問題が解決します。

于 2013-01-30T07:36:37.803 に答える