画像のサイズを変更するための小さな WCF/WPF アプリを作成していますが、クライアントからサービスにサイズ 28K の画像を送信しようとすると、WCF は私に悲しみを与えています。小さい画像を送信すると、サービスは正常に機能します。私はすぐにこれが構成の問題であると想定し、バインディング構成の MaxArrayLength プロパティに関する投稿を見て Web をトロールしました。クライアントとサーバーの両方でこれらの設定の制限を最大 2147483647 に引き上げましたが、それでも次のエラーが発生します。
メッセージを逆シリアル化しようとしているときにフォーマッタが例外をスローしました: パラメータhttp://mywebsite.com/services/servicecontracts/2009/01:OriginalImageを逆シリアル化しようとしているときにエラーが発生しました。InnerException メッセージは、「System.Drawing.Image 型のオブジェクトの逆シリアル化でエラーが発生しました。XML データの読み取り中に、最大配列長のクォータ (16384) を超えました。このクォータは、XML リーダーの作成時に使用される XmlDictionaryReaderQuotas オブジェクトの MaxArrayLength プロパティを変更することで増やすことができます。詳細については、InnerException を参照してください。
クライアントとサーバーの構成を同じにしましたが、次のようになります。
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="LogoResizer.WCF.ServiceTypes.ImageResizerService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:900/mex/"/>
<add baseAddress="net.tcp://localhost:9000/" />
</baseAddresses>
</host>
<endpoint binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
私のクライアント設定は次のようになります:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:9000/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_ImageResizerServiceContract"
contract="ImageResizerService.ImageResizerServiceContract"
name="NetTcpBinding_ImageResizerServiceContract">
<identity>
<userPrincipalName value="me@domain.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
これらの値を何に設定しても、wcf は 16384 より大きいため、ファイルをシリアル化できないというエラーが表示されます。何かアイデアはありますか?
更新: userPrincipalName タグの電子メール アドレスは、プライバシー保護のために変更されています