El cambio de la MaxArrayLength de la propiedad en el XmlDictionaryReaderQuotas objeto que se utiliza a la hora de crear el XML lector

StackOverflow https://stackoverflow.com/questions/1035600

Pregunta

Me estoy haciendo de la siguiente excepción al enviar ( o recibir ) una matriz de bytes a un C# servicio.

There was an error deserializing the object of type System.Byte[]. 
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 6, position 34838.'.  
Please see InnerException for more details

Por lo que puedo entender el XmlDictionaryreader es creado automáticamente por el webservice.

Así que, ¿cómo puedo cambiar el "MaxArrayLength" propiedad?

Este es el código de la implementación:

    public string addFile(string sharePointServer, string documentLibrary, 
                          byte[] content, string fileName) 
    {
        try
        {
            SPWeb spWeb = new SPSite(sharePointServer).OpenWeb();
            SPFolder spFolder = spWeb.GetFolder(documentLibrary);
            SPFileCollection spFileCollection = spFolder.Files;
            SPFile spFile = spFileCollection.Add(fileName, content, true);
            return spFile.TimeCreated.ToLongDateString() + "::" + spFile.Title;
        } 
            catch (Exception ex) 
        {
            throw ex;
        }
    }

Los archivos < 16kb se cargan.

Archivos > 16kb no lo son.

Los archivos de > 10 mb se descargan sin problema.

Donde es que la propiedad configurado?

¿Fue útil?

Solución

¿Es un servicio WCF? Si es así, puede cambiar la longitud máxima del enlace como se ve en esta publicación SO:

publicación

P.S. ¿Por qué usaría un Servicio personalizado cuando hay servicios OOTB Sharepoint que pueden cargar archivos? es decir, el Lists.asmx como en este artículo:

artículo

Otros consejos

Añadir un <readerQuotas> elemento dentro de la <binding> elemento y añadir MaxArrayLength la propiedad

 <bindings>
     <wsHttpBinding>
         <binding name ="Your WSHttpBinding Name" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647">
             <security mode="None"></security>
             <readerQuotas maxStringContentLength="134217728" maxArrayLength="2147483647" />
             <reliableSession enabled="true"/>
         </binding>
     </wsHttpBinding>
 </bindings>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top