最大数组长度配额 [英] Maximum array length quota

查看:191
本文介绍了最大数组长度配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个小的WCF / WPF应用程序来调整图像,但WCF是给我的悲伤,当我尝试大小28K的图像从客户端发送到我的服务。该服务工作正常,当我把它较小的图像。我立刻认为这是一个配置的问题,我已经搜罗了网上看关于我的绑定配置的MaxArrayLength财产的帖子。香港专业教育学院调升同时在客户端和服务器上的这些设置的限制,以最大限度2147483647但我仍得到以下错误:

I'm writing a small WCF/WPF app to resize images but WCF is giving me grief when I try to send an image of size 28K to my service from the client. The service works fine when I send it smaller images. I immediately assumed that this was a configuration issue and I've trawled the web looking at posts regarding the MaxArrayLength property in my binding configuration. Ive upped the limits on these settings on both the client and server to the maximum 2147483647 but still I get the following error:

而试图反序列化消息格式化的异常:有尝试反序列化错误   参数 http://mywebsite.com/services/servicecontracts/2009/01:OriginalImage。   设置InnerException消息是'有一个错误反序列化类型为System.Drawing.Image对象。   最大的数组长度配额(16384)时,超过了读取XML数据。创建XML阅读器对象时,使用此配额可能会增加改变在XmlDictionaryReaderQuotas的MaxArrayLength财产。。请参阅的InnerException了解更多详情。

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://mywebsite.com/services/servicecontracts/2009/01:OriginalImage. The InnerException message was 'There was an error deserializing the object of type System.Drawing.Image. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.'. Please see InnerException for more details.

我做我的客户端和服务器CONFIGS相同的,他们看起来像下面这样: 服务器:

I've made my client and server configs the same and they look like the following: Server:

<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>

和我的客户端的配置是这样的:

and my client config looks like:

 <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任何想法连载我的档案?

It seems no matter what I set these values to I still get an error saying wcf cannot serialize my file because its greater than 16384. Any ideas?

更新:中的UserPrincipalName标记的电子邮件地址已经改变了我的隐私。

Update: the email address in the userPrincipalName tag has been altered for my privacy

推荐答案

我的坏 - 我忘了我的申请绑定配置我在我的服务器端配置端点。服务器配置应为:

My Bad - I forgot to apply my binding configuration to my endpoint in my server-side config. The server config should read:

<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="2147483647"
							  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 bindingConfiguration="NetTcpBinding_ImageResizerServiceContract" binding="netTcpBinding" contract="LogoResizer.WCF.ServiceContracts.IImageResizerService" />
			<endpoint  address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
		</service>
	</services>
</system.serviceModel>

请注意已经被添加到所述netTcp端点bindingConfiguration =NetTcpBinding_ImageResizerServiceContract。我的应用程序现在与较大的图像。甜。

Note the bindingConfiguration="NetTcpBinding_ImageResizerServiceContract" has been added to the netTcp endpoint. My app now works with larger images. Sweet.

这篇关于最大数组长度配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆