Bug 206 - Parameter array length does not match the number of message body parts Exception
Summary: Parameter array length does not match the number of message body parts Exception
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2011-08-05 16:56 UTC by David
Modified: 2011-08-24 11:52 UTC (History)
5 users (show)

Tags: WebHttpBinding ReaderQuotas Exception WCF json MonoTouch
Is this bug a regression?: ---
Last known good build:


Attachments
Solution that can be used to recreate (47.74 KB, application/octet-stream)
2011-08-09 13:27 UTC, David
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description David 2011-08-05 16:56:08 UTC
I am getting the following exception when trying to call a WCF service using Monotouch.  I posted this on StackOverflow (http://stackoverflow.com/questions/6947887/monotouch-parameter-array-length-does-not-match-the-number-of-message-body-parts) and the answer that came back was to set WebHttpBinding.ReaderQuotas.MaxArrayLength = int.MaxValue, however WebHttpBinding does not have a ReaderQuotas Property.  I checked in VS2010 on a WPF project and WebHttpBinding does have a ReaderQuotas property so it appears that this property has been omitted in MonoTouch (or perhaps Mono itself)

Exception:

Parameter array length does not match the number of message body parts at
System.ServiceModel.Dispatcher.WebMessageFormatter+WebClientMessageFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x0003e] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs:310    at System.ServiceModel.Description.WebHttpBehavior+ClientPairFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion messageVersion, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs:142    at System.ServiceModel.MonoInternal.ClientRuntimeChannel.CreateRequest (System.ServiceModel.Dispatcher.ClientOperation op, System.Object[] parameters) [0x0001e] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:611    at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x0002d] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:512    at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:482    at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:462
Comment 1 Rolf Bjarne Kvinge [MSFT] 2011-08-09 06:03:15 UTC
Atsushi, do you know a solution for this problem?
Comment 2 Atsushi Eno 2011-08-09 11:09:22 UTC
XmlDictionaryReaderQuotas has nothing to do with message parameter array length.

Please provide reproducible test case that we can examine. The code snippet on that stackoverflow page is not sufficient to run.
Comment 3 David 2011-08-09 13:27:09 UTC
Created attachment 98 [details]
Solution that can be used to recreate

Here (attachement) is a quick and dirty app that will recreate the problem.  Click the Go button.
Comment 4 David 2011-08-12 12:49:13 UTC
provided info
Comment 5 David 2011-08-16 15:39:51 UTC
Atsushi,  I was wondering if the attachment that I provided you has been adequate for you to recreate the issue.  Is there anything I can do to help?
Comment 6 Atsushi Eno 2011-08-16 22:19:59 UTC
Unlike other components MonoTouch bug reports that involves WCF is not very quickly fixable (as well as those in Moonlight) - it first needs to be examined using *full* WCF which has different set of API (e.g. no Async pattern). It becomes complicated when repro code is not really minimized (it is also needed to make it into our nunit tests).

Anyways I already extracted "minimized" test case that reproduces the issue as below:

using System;

namespace br
{
	public class Driver
	{
		public static void Main ()
		{
			System.ServiceModel.WebHttpBinding bnd = new System.ServiceModel.WebHttpBinding (System.ServiceModel.WebHttpSecurityMode.Transport);
			System.ServiceModel.EndpointAddress addr = new System.ServiceModel.EndpointAddress (new Uri("https://this.does.not.matter.com/service.svc"));
			DHIWebService.DHIServiceClient service = new DHIWebService.DHIServiceClient (bnd, addr);
			service.Endpoint.Behaviors.Add(new System.ServiceModel.Description.WebHttpBehavior());
			DHIWebService.Login login = new DHIWebService.Login { InstitutionId = 138.ToString ("D4"), CompanyNumber = 0, Password = "Junk", UserName = "Junk" };
			DHIWebService.LoginRequest loginRequest = new DHIWebService.LoginRequest (new DHIWebService.ClientLoginData(){ UserName = "testuser", Password = "1" }, login);
			service.LoginCompleted += delegate (object o, DHIWebService.LoginCompletedEventArgs e) {
				if (e.Error != null)
					Console.WriteLine (e.Error);
				else
					Console.WriteLine ("OK");
			};
			service.LoginAsync(loginRequest);
			Console.ReadLine ();
		}
	}
}


namespace DHIWebService
{
    using System.Runtime.Serialization;
    
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="ClientLoginData", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
    public partial class ClientLoginData : object
    {
        
        private int CompanyNumberField;
        
        private string InstitutionIdField;
        
        private string PasswordField;
        
        private string UserNameField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int CompanyNumber
        {
            get
            {
                return this.CompanyNumberField;
            }
            set
            {
                this.CompanyNumberField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string InstitutionId
        {
            get
            {
                return this.InstitutionIdField;
            }
            set
            {
                this.InstitutionIdField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
        public string Password
        {
            get
            {
                return this.PasswordField;
            }
            set
            {
                this.PasswordField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
        public string UserName
        {
            get
            {
                return this.UserNameField;
            }
            set
            {
                this.UserNameField = value;
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute(Name="Login", Namespace="http://schemas.datacontract.org/2004/07/Domain.Models")]
    public partial class Login : object
    {
        
        private int CompanyNumberField;
        
        private string InstitutionIdField;
        
        private string PasswordField;
        
        private string UserNameField;
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public int CompanyNumber
        {
            get
            {
                return this.CompanyNumberField;
            }
            set
            {
                this.CompanyNumberField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute()]
        public string InstitutionId
        {
            get
            {
                return this.InstitutionIdField;
            }
            set
            {
                this.InstitutionIdField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
        public string Password
        {
            get
            {
                return this.PasswordField;
            }
            set
            {
                this.PasswordField = value;
            }
        }
        
        [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
        public string UserName
        {
            get
            {
                return this.UserNameField;
            }
            set
            {
                this.UserNameField = value;
            }
        }
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(Namespace="IBEWebSvc", ConfigurationName="DHIWebService.IDHIService")]
    public interface IDHIService
    {
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="IBEWebSvc/IDHIService/Login", ReplyAction="IBEWebSvc/IDHIService/LoginResponse")]
		[System.ServiceModel.Web.WebInvoke(BodyStyle=System.ServiceModel.Web.WebMessageBodyStyle.Wrapped)]
        System.IAsyncResult BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState);
        
        DHIWebService.LoginResponse EndLogin(System.IAsyncResult result);
        
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.MessageContractAttribute(WrapperName="Login", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
    public partial class LoginRequest
    {
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=0)]
        public DHIWebService.ClientLoginData clientLoginData;
        
        [System.ServiceModel.MessageBodyMemberAttribute(Namespace="IBEWebSvc", Order=1)]
        public DHIWebService.Login credentials;
        
        public LoginRequest()
        {
        }
        
        public LoginRequest(DHIWebService.ClientLoginData clientLoginData, DHIWebService.Login credentials)
        {
            this.clientLoginData = clientLoginData;
            this.credentials = credentials;
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.MessageContractAttribute(WrapperName="LoginResponse", WrapperNamespace="IBEWebSvc", IsWrapped=true)]
    public partial class LoginResponse
    {
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public interface IDHIServiceChannel : DHIWebService.IDHIService, System.ServiceModel.IClientChannel
    {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class LoginCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
    {
        
        private object[] results;
        
        public LoginCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState)
        {
            this.results = results;
        }
        
        public DHIWebService.LoginResponse Result
        {
            get
            {
                base.RaiseExceptionIfNecessary();
                return ((DHIWebService.LoginResponse)(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class DHIServiceClient : System.ServiceModel.ClientBase<DHIWebService.IDHIService>, DHIWebService.IDHIService
    {
        
        private BeginOperationDelegate onBeginLoginDelegate;
        
        private EndOperationDelegate onEndLoginDelegate;
        
        private System.Threading.SendOrPostCallback onLoginCompletedDelegate;
        
        public DHIServiceClient()
        {
        }
        
        public DHIServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName)
        {
        }
        
        public DHIServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress)
        {
        }
        
        public DHIServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress)
        {
        }
        
        public DHIServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress)
        {
        }
        
        public event System.EventHandler<LoginCompletedEventArgs> LoginCompleted;
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        System.IAsyncResult DHIWebService.IDHIService.BeginLogin(DHIWebService.LoginRequest request, System.AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginLogin(request, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        DHIWebService.LoginResponse DHIWebService.IDHIService.EndLogin(System.IAsyncResult result)
        {
            return base.Channel.EndLogin(result);
        }
        
        private System.IAsyncResult OnBeginLogin(object[] inValues, System.AsyncCallback callback, object asyncState)
        {
            DHIWebService.LoginRequest request = ((DHIWebService.LoginRequest)(inValues[0]));
            return ((DHIWebService.IDHIService)(this)).BeginLogin(request, callback, asyncState);
        }
        
        private object[] OnEndLogin(System.IAsyncResult result)
        {
            DHIWebService.LoginResponse retVal = ((DHIWebService.IDHIService)(this)).EndLogin(result);
            return new object[] {
                    retVal};
        }
        
        private void OnLoginCompleted(object state)
        {
            if ((this.LoginCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.LoginCompleted(this, new LoginCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void LoginAsync(DHIWebService.LoginRequest request)
        {
            this.LoginAsync(request, null);
        }
        
        public void LoginAsync(DHIWebService.LoginRequest request, object userState)
        {
            if ((this.onBeginLoginDelegate == null))
            {
                this.onBeginLoginDelegate = new BeginOperationDelegate(this.OnBeginLogin);
            }
            if ((this.onEndLoginDelegate == null))
            {
                this.onEndLoginDelegate = new EndOperationDelegate(this.OnEndLogin);
            }
            if ((this.onLoginCompletedDelegate == null))
            {
                this.onLoginCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnLoginCompleted);
            }
            base.InvokeAsync(this.onBeginLoginDelegate, new object[] {
                        request}, this.onEndLoginDelegate, this.onLoginCompletedDelegate, userState);
        }
        
    }
}


I had already looked in the issue, but it did not seem to be very quickly fixable. I'll try another debugging later today.
Comment 7 David 2011-08-17 12:45:45 UTC
thanks forthe update.  If you need anything from me please let me know.
Comment 8 Atsushi Eno 2011-08-23 23:23:33 UTC
Finally this should be fixed in mono master and 2.10 branches (with a bunch of fixes; 2be522d 78c5897 6bdb4ba 106fdeb bde305b 133c531 3d385eb in master). The fixes should be included in the next release. Please reopen if it still didn't work.
Comment 9 David 2011-08-24 11:52:54 UTC
Thank you for your help.  I Look forward to the next release.