开发者

upload picture over 16kb vs2010 c# asp.net

I want to uplode large pictures (over 16kb) to database.(I succeeded with small pictures) I have already changed the MaxArrayLength to 2147483647 (by default it was 16384) in all places it found. but still I get this error message after debbuging:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:PicToAdd. The InnerException message was 'There was an error deserializing the object of type BL.BE.Picture. 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. Line 1, position 41545.'. Please see InnerException for more details source code:

Line 218:      开发者_如何转开发  public string BLS_AddPicture(BL.BE.Picture PicToAdd) {
Line 219:            **return base.Channel.BLS_AddPicture(PicToAdd);**
Line 220:        }

What Can I do to fix it as quick as possible!!! Thanks


You have to change the setting XmlDictionaryReaderQuotas.MaxArrayLength in your WCF configuration.

You can do it in the config file:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding ...>
                <readerQuotas maxDepth="32" 
                              maxStringContentLength="8192"
                              maxArrayLength="16384"
                              maxBytesPerRead="4096" 
                              maxNameTableCharCount="16384" />

or in code:

XmlDictionaryReaderQuotas lOQuotas = new XmlDictionaryReaderQuotas()
           {
                    MaxArrayLength = Int32.MaxValue,
                    MaxBytesPerRead = Int32.MaxValue,
                    MaxDepth = Int32.MaxValue,
                    MaxNameTableCharCount = Int32.MaxValue,
                    MaxStringContentLength = Int32.MaxValue
           };

myBinding.ReaderQuotas = lOQuotas;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜