【问题标题】:Getting "The image cannot be decoded. The image header might be corrupted" error while reading list of images from WCF service从 WCF 服务读取图像列表时出现“图像无法解码。图像标头可能已损坏”错误
【发布时间】:2014-06-11 06:36:34
【问题描述】:
我在数据库中以字节的形式保存我的图像。当我尝试使用 WCF 从数据库中获取图像时,它给了我错误 “图像无法解码。图像标题可能是损坏。”。为此,我增加了 web config 的大小。
以下是我正在使用的代码,但我遇到了同样的问题。请让我知道我错在哪里。
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
【问题讨论】:
标签:
c#
asp.net
wcf
list
byte
【解决方案1】:
在 wcf 中需要添加下面的代码才能摆脱这个错误
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="10485760">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
还需要在客户端机器上的 app.config 中添加同样的内容
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="10485760">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>