Click here to Skip to main content
15,891,136 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: connection string Pin
dinusahu21-Nov-14 22:38
dinusahu21-Nov-14 22:38 
GeneralRe: connection string Pin
jkirkerx22-Nov-14 8:32
professionaljkirkerx22-Nov-14 8:32 
QuestionDatagrid vs Generating table and rows Pin
neualex21-Nov-14 2:30
neualex21-Nov-14 2:30 
QuestionASP.net Pin
nikky13.batra@gmail.com20-Nov-14 19:21
nikky13.batra@gmail.com20-Nov-14 19:21 
SuggestionRe: ASP.net Pin
ZurdoDev21-Nov-14 2:23
professionalZurdoDev21-Nov-14 2:23 
Questionsome questions Pin
Member 1124450118-Nov-14 8:27
Member 1124450118-Nov-14 8:27 
AnswerRe: some questions Pin
ZurdoDev18-Nov-14 8:51
professionalZurdoDev18-Nov-14 8:51 
QuestionMaxArrayLength Exception for large data blocks Pin
Tim Mackey (2)18-Nov-14 8:20
Tim Mackey (2)18-Nov-14 8:20 
This question is a re-post because I could not find it under 'My Questions' for the account in my name, and wasn't sure if it ended up in the ASP.NET forum. Administrator, please feel free to delete the earlier posting and this comment.


Hi Everyone,

I cannot get this message to go away:

"An Exception occured: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:deviceInfo. The InnerException message was 'There was an error deserializing the object of type LiveControl.ImageDataResponse. 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 24868.'. Please see InnerException for more details."

I've tried dozens of possible solutions to the problem of moving large blocks of data from a Winforms client to a WCF server, to no avail. I've Googled until I'm bleary eyed. Still no solution to this message. The MaxArrayLength in app.config is 2147483647. Here is the app.config file:

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="LiveControl.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    </sectionGroup>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="LiveControl.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
  </startup>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_IMyMessage" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="4194304" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="WSDualHttpBinding_ILiveCtrlService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
          <readerQuotas maxDepth="4194304" maxStringContentLength="8192"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Message">
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="WSDualHttpBinding_ILiveCtrlEvents" />
        <binding name="WSDualHttpBinding_ILiveCtrlService1" />
        <binding name="WSDualHttpBinding_IMyMessage1" />
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:53604/LiveCtrlService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ILiveCtrlService"
        contract="ServiceReference.ILiveCtrlService" name="WSDualHttpBinding_ILiveCtrlService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost:53604/LiveCtrlService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IMyMessage"
        contract="ServiceReference.IMyMessage" name="WSDualHttpBinding_IMyMessage">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost:53604/LiveCtrlService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ILiveCtrlService1"
        contract="LiveControlService.ILiveCtrlService" name="WSDualHttpBinding_ILiveCtrlService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost:53604/LiveCtrlService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IMyMessage1"
        contract="LiveControlService.IMyMessage" name="WSDualHttpBinding_IMyMessage1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost:53604/LiveCtrlService.svc"
        binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ILiveCtrlEvents"
        contract="LiveControlService.ILiveCtrlEvents" name="WSDualHttpBinding_ILiveCtrlEvents">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
  <userSettings>
    <LiveControl.Properties.Settings>
      <setting name="Device_Name" serializeAs="String">
        <value />
      </setting>
      <setting name="Owner_Name" serializeAs="String">
        <value />
      </setting>
    </LiveControl.Properties.Settings>
  </userSettings>
  <applicationSettings>
    <LiveControl.Properties.Settings>
      <setting name="Device_ID" serializeAs="String">
        <value>1add22ed-af20-4ef8-aeb9-caad8fa9ff08</value>
      </setting>
    </LiveControl.Properties.Settings>
  </applicationSettings>
</configuration>


...and the Service interface is this...

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
 
// Windows Communication Foundation - WCF

namespace LiveControl
{
    public interface IMyMessageCallback
    {
        [OperationContract(IsOneWay = true)]
        void OnCallback(string message);
    }
 
    [ServiceContract(CallbackContract = typeof(IMyMessageCallback), SessionMode = SessionMode.Required)]
    public interface IMyMessage
    {
        [OperationContract(IsOneWay = true)]
        void MessageToServer(string message);
        // TODO: Add your service operations here
    }
 
    //-----------------------------------------------------------
    interface ILiveCtrlEventsCallback
    {
        [OperationContract(IsOneWay = true)]
        void OnMessageReceived(string message);
    }
 
    //-----------------------------------------------------------
    [ServiceContract(SessionMode = SessionMode.Required,
                     CallbackContract = typeof(ILiveCtrlEventsCallback))]
    interface ILiveCtrlEvents
    {
        [OperationContract(IsOneWay = true)]
        void Subscribe(Guid deviceGuid, string deviceName, string ownerName);
 
        [OperationContract]
        void Unsubscribe(Guid deviceGuid);
 
        [OperationContract(IsOneWay = true)]
        void Connect(Guid deviceGuid);
 
        [OperationContract]
        void Disconnect();
 
    }
 
    //-----------------------------------------------------------
    [ServiceContract]
    public interface ILiveCtrlService
    {
        [OperationContract]
        int GetNextValueSvc(int value);
 
        [OperationContract]
        string GetDataSvc(int value);
 
        [OperationContract]
        CompositeType GetDataUsingDataContractSvc(CompositeType composite);
 
        [OperationContract]
        string GetImageUrlSvc(string slide, int focus, int x1off, int y1off, int width, int height);
 
        [OperationContract]
        string GetPreviewImageUrlSvc(string slide);
 
        [OperationContract]
        FocusCaps GetFocusCapsSvc();
 
        [OperationContract]
        DeviceInfo[] GetDeviceInfoListSvc();
 
        [OperationContract]
        void SetDeviceInfoSvc(DeviceInfo deviceInfo);
 
        [OperationContract]
        ImageDataRequest SendImageDataSvc(ImageDataResponse imageData);
    }
 
    [DataContract]
    public class FocusCaps
    {
        [DataMember]
        public int Min { get; set; }
 
        [DataMember]
        public int Max { get; set; }
        
        [DataMember]
        public int Default { get; set; }
    }
 
    //-----------------------------------------------------------
    [DataContract]
    public class ImageDataResponse
    {
        [DataMember]
        public Guid deviceGuid { get; set; }
 
        [DataMember]
        public bool isChunking { get; set; }
 
        [DataMember]
        public int chunkSize { get; set; }
 
        [DataMember]
        public int chunksTotal { get; set; }
 
        [DataMember]
        public int wholeChunks { get; set; }
 
        [DataMember]
        public int partialChunks { get; set; }
 
        [DataMember]
        public int chunksRemaining { get; set; }
 
        [DataMember]
        public int Size { get; set; }
 
        [DataMember]
        public byte[] Data { get; set; }
    }
 
    //-----------------------------------------------------------
    [DataContract]
    public class ImageDataRequest
    {
        [DataMember]
        public Guid deviceGuid { get; set; }
 
        [DataMember]
        public bool request { get; set; }     // DeviceRequest DataMembers are valid

        [DataMember]
        public string slide { get; set; }
 
        [DataMember]
        public int focus { get; set; }
 
        [DataMember]
        public int x1off { get; set; }
 
        [DataMember]
        public int y1off { get; set; }
 
        [DataMember]
        public int width { get; set; }
 
        [DataMember]
        public int height { get; set; }
    }
 
    //-----------------------------------------------------------
    [DataContract]
    public class DeviceInfo
    {
        [DataMember]
        public Guid device_guid { get; set; }
 
        [DataMember]
        public string device_owner{ get; set; }
 
        [DataMember]
        public string device_name { get; set; }
 
        [DataMember]
        public string user_name { get; set; }
 
        [DataMember]
        public bool online { get; set; }
 
        [DataMember]
        public bool available { get; set; }
 
        public ICommunicationObject comm_obj;
    }
 
    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";
 
        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }
 
        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
 
}


My client app is sending ImageDataResponse.Data[1M max] blocks of various sizes of image data to the server:

C#
ImageDataResponse imageData = new ImageDataResponse();

// copy image data to byte array
Bitmap bitmap = new Bitmap(pictureBox2.Image);
imageData.Size = bitmap.Height * bitmap.Width;
imageData.Data = new byte[imageData.Size];

using (var memoryStream = new MemoryStream())
{
	bitmap.Save(memoryStream, ImageFormat.Jpeg);
	imageData.Data = memoryStream.ToArray();
}
imageData.Size = imageData.Data.Count();

ImageDataRequest imgDataReq = new ImageDataRequest();

imgDataReq = m_LiveCtrlService.SendImageDataSvc(imageData);


I'm a beginner and any suggestions that would enable sending large Byte[] arrays to the server would be greatly appreciated. Smile | :)

Thank you in advance.
AnswerRe: MaxArrayLength Exception for large data blocks Pin
Richard MacCutchan18-Nov-14 21:24
mveRichard MacCutchan18-Nov-14 21:24 
QuestionMaxArrayLength Exception for large data blocks Pin
Tim Mackey (2)18-Nov-14 4:23
Tim Mackey (2)18-Nov-14 4:23 
Questionstate management-sessions Pin
Member 1107145116-Nov-14 23:45
Member 1107145116-Nov-14 23:45 
AnswerRe: state management-sessions Pin
David Mujica17-Nov-14 3:19
David Mujica17-Nov-14 3:19 
AnswerRe: state management-sessions Pin
jkirkerx17-Nov-14 8:48
professionaljkirkerx17-Nov-14 8:48 
QuestionCross-page postback to new window Pin
BobbyStrain14-Nov-14 17:53
BobbyStrain14-Nov-14 17:53 
AnswerRe: Cross-page postback to new window Pin
DamithSL14-Nov-14 19:24
professionalDamithSL14-Nov-14 19:24 
AnswerRe: Cross-page postback to new window Pin
Dusara Maulik14-Nov-14 19:57
Dusara Maulik14-Nov-14 19:57 
GeneralRe: Cross-page postback to new window Pin
BobbyStrain15-Nov-14 8:17
BobbyStrain15-Nov-14 8:17 
QuestionCSS positioning issue for IE 11 Suggestion required Pin
Tridip Bhattacharjee14-Nov-14 3:23
professionalTridip Bhattacharjee14-Nov-14 3:23 
AnswerRe: CSS positioning issue for IE 11 Suggestion required Pin
jkirkerx14-Nov-14 8:24
professionaljkirkerx14-Nov-14 8:24 
GeneralRe: CSS positioning issue for IE 11 Suggestion required Pin
Tridip Bhattacharjee17-Nov-14 20:51
professionalTridip Bhattacharjee17-Nov-14 20:51 
AnswerRe: CSS positioning issue for IE 11 Suggestion required Pin
JR00917-Nov-14 23:07
professionalJR00917-Nov-14 23:07 
GeneralRe: CSS positioning issue for IE 11 Suggestion required Pin
Tridip Bhattacharjee18-Nov-14 4:21
professionalTridip Bhattacharjee18-Nov-14 4:21 
QuestionWhy is the ReportViewer Control not working on server Pin
saeed389513-Nov-14 7:32
saeed389513-Nov-14 7:32 
AnswerRe: Why is the ReportViewer Control not working on server Pin
jaimin851-Dec-14 23:44
jaimin851-Dec-14 23:44 
Questionhow to create web service in asp.net c# step by step Pin
owais_ahmed_ansari13-Nov-14 3:02
owais_ahmed_ansari13-Nov-14 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.