题
我在写小WCF/WPF应用程序,以调整的图像,但WCF是让我悲伤时,我尝试送的图像大小的28k到我的服务的客户。该服务的工作现在我把它送较小的图像。我立即假定,这是一个结构问题,我已经拖网的网页看员额有关的MaxArrayLength酒店在我结合的配置。我已经加大了限制,这些设置的两客户和服务的最大2147483647但我仍然得到以下错误:
格式把一个例外,同时试图deserialize的信息:有一个错误,同时试图deserialize 参数 http://mywebsite.com/services/servicecontracts/2009/01:OriginalImage.内部消息是有一个错误反序列化对象的种类型的系统。图。图像。最大的阵列的长度配额(16384)已经超过,而读XML数据。这种配额可能会增加通过改变MaxArrayLength财产上XmlDictionaryReaderQuotas对象时使用的创建XML读者。'.请参阅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不serialize我的文件,因为其更大的比16384.任何想法?
更新: 电子邮件地址范围内标已经改变了我的隐私
解决方案
我的坏 - 我忘了我的绑定配置适用于我在我的服务器端配置端点。服务器配置应为:
<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>
请注意的bindingConfiguration =“NetTcpBinding_ImageResizerServiceContract”已被添加到netTcp端点。我的应用程序现在可与较大的图像。甜。
其他提示
请在结合添加<readerQuotas>
。
这是主要的问题,同时上载和下载的字节[],它解决了我的问题。
<basicHttpBinding>
<binding name="ServicesBinding" transferMode="Streamed" maxBufferSize="200000000"
maxReceivedMessageSize="200000000" messageEncoding="Text"
receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
我利用Microsoft SDK SvcConfigEditor.你有这样的如果你使用Visual Studio(其中有自己版本)。它也是一个免费下载。
你的硬盘驱动器上(检查程序文件和程序文件(86)):
C:\Program 文件(86)\Microsoft软件开发工具包\Windows\版本7.0A\Bin ETFX4.0 工具\SvcConfigEditor.exe
C:\Program 文件\Microsoft软件开发工具包\Windows\版本7.1\Bin ETFX4.0 工具\SvcConfigEditor.exe
如果你有多安装微软SDK,版本使用将取决于什么样的版本。净你的发展。该工具将引发一个错误让你知道,你想打开.dll文件下错误的版本。
使用的工具,指你的服务。dll文件,并让工具。这是特别有益的,如果你有服务的谈话服务(代理服务)。此外,请记住,你可能会需要配置设置你的客户(应用程序)和服务器配置(在服务).
我是缺少一个配置服务器上的侧端点。我必须做的两件事情:
- 把一个终点我的服务器上侧配置,用SvcConfigEditor
- 记得设置MaxArrayLength在SvcConfigEditor工具
此外,ASP.NET 正在挑关于这个价值,所以你可能会尝试简化配置结合,并把它关闭:
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
它,s工作,先前示出的net.tcp的参考://myservice.com/Ac_Service.svc/mex浏览WCF服务时但现在它的 http://myservice.com/Ac_Service.svc?wsdl
将它在未来也工作,而没有任何问题。