I have found similar topics in this very forum and also online, but none of them could give me a solution or give an explanation about where I am going wrong. All the solutions point to changing the readerQuota size or increasing the other attributes of the config settings.
It will be of great help if someone could point out my mistakes and I am facing my deadlines around the corner. I have a web application which has uses the WCF service to upload a file on to the DataBase. I am streaming the file in Byte Array and passing it over the function. Both service and the application will be hosted on IIS. Please the code snippet which calls the WCF Service function : CreateAttachments
Dim fInfo As New System.IO.FileInfo(dtAttachments.Rows(iCounter)("File Location").ToString())
Dim numBytes As Long = fInfo.Length
Dim fStream As New System.IO.FileStream(dtAttachments.Rows(iCounter)("File Location").ToString(), IO.FileMode.Open, IO.FileAccess.Read)
Dim br As New System.IO.BinaryReader(fStream)
Dim data As Byte() = br.ReadBytes(CInt(numBytes))
iStatus = proxy.CreateAttachements(iTicketID, dtAttachments.Rows(iCounter)("File Name").ToString(), data)
I am getting the following error on executing the final statement of the code shown above:
"The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 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".
Here is the WCF Service Config File.
<binding name="HttpBinding_MTOM" messageEncoding="Mtom" transferMode="Streamed" maxBufferSize="10485760" maxReceivedMessageSize="67108864">
<transport clientCredentialType="None" />
<service name="XXXDataLayer.DataLayerService" behaviorConfiguration="XXXDataLayer.Service1Behavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="HttpBinding_MTOM" contract="XXXDataLayer.IXXXDataLayer" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
<httpRuntime maxRequestLength="2097151" />
And here is the Web Application Config file which consumes the WCF Service.
maxBufferSize="10485760" maxBufferPoolSize="67108864" maxReceivedMessageSize="67108864"
<readerQuotas maxDepth="64" maxStringContentLength="214748364" maxArrayLength="214748364"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
contract="XXXDataLayer.IXXXDataLayer" name="BasicHttpBinding_IXXXDataLayer" />
I have run this application in both visual studio and also from a website hosted on IIS. In both cases I seem to have problems. Kindly let me know the mistake that I have made or if you have any alternate solution for the given situation.
Thanks and regards,
Great that it worked!
About the service reference, not really, once you update / delete+add the service reference, it will download the metadata again from the server to recreate the config file. A couple of options is to save the original app.config, then replace it after updating the service reference, or you can use the svcutil.exe tool (http://msdn.microsoft.com/en-us/library/aa347733.aspx), in which you can specify the /noconfig option (so it won't generate config).