简体   繁体   English

得到“图像无法解码。 从WCF服务读取图像列表时,图像标题可能已损坏”错误

[英]Getting “The image cannot be decoded. The image header might be corrupted” error while reading list of images from WCF service

I'm saving my images in the form of bytes in the database.When I try to fetch the images from database using WCF , it gives me the error "The image cannot be decoded. The image header might be corrupted." 我将图像以字节的形式保存在数据库中。当我尝试使用WCF从数据库中获取图像时,出现错误“图像无法解码。图像头可能已损坏”。 .For this , I have increased the size in web config. 为此,我增加了Web配置的大小。 Below is the code I'm using but I'm getting the same problem.Please Let me know where I'm wrong. 以下是我正在使用的代码,但我遇到了同样的问题。请告诉我我错了。

<bindings>
      <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000"
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
               maxArrayLength="200000000"
               maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>

In wcf need to add below code in order to get rid off this error 在wcf中需要添加以下代码以摆脱此错误

<bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760">
          <readerQuotas maxDepth="2147483647"
                         maxStringContentLength="2147483647"
                         maxArrayLength="2147483647"
                         maxBytesPerRead="2147483647"
                         maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

Also needs to add the same in app.config on client machine 还需要在客户端计算机上的app.config中添加相同的内容

<bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760">
          <readerQuotas maxDepth="2147483647"
                         maxStringContentLength="2147483647"
                         maxArrayLength="2147483647"
                         maxBytesPerRead="2147483647"
                         maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM