Bug 205 - Exposing IEnumberable<> on a WCF service fails
Summary: Exposing IEnumberable<> on a WCF service fails
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Other Other
: --- blocker
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-05 16:15 UTC by Jean-Philippe Leclerc
Modified: 2011-08-09 15:04 UTC (History)
5 users (show)

Tags: wcf serialize
Is this bug a regression?: ---
Last known good build:

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 NOT_REPRODUCIBLE

Description Jean-Philippe Leclerc 2011-08-05 16:15:12 UTC
This bug still exist in Mono version 2.10.3:
https://bugzilla.novell.com/show_bug.cgi?id=688414

System.Runtime.Serialization.SerializationException: Type 'System.Int32[]' is unexpected. The type should either be registered as a known type, or DataContractResolver should be used.
  at System.Runtime.Serialization.DataContractSerializer.WriteStartObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00299] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:504 
  at System.Runtime.Serialization.XmlObjectSerializer.WriteObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:106 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.WriteMessagePart (System.Xml.XmlDictionaryWriter writer, System.ServiceModel.Description.MessageBodyDescription desc, System.ServiceModel.Description.MessagePartDescription partDesc, System.Object obj) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:570 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00091] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:562 
  at System.ServiceModel.Channels.BodyWriter.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs:57 
  at System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs:328 
  at System.ServiceModel.Channels.Message.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:159 
  at System.ServiceModel.Channels.Message.WriteBody (System.Xml.XmlDictionaryWriter writer) [0x0001c] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:146 
  at System.ServiceModel.Channels.Message.OnWriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:260 
  at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00026] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:170 
  at System.ServiceModel.Channels.TextMessageEncoder.WriteMessage (System.ServiceModel.Channels.Message message, System.IO.Stream stream) [0x00043] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs:100 
  at System.ServiceModel.Channels.HttpRequestChannel.BeginProcessRequest (System.ServiceModel.Channels.HttpChannelRequestAsyncResult result) [0x002d7] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:159 
  at System.ServiceModel.Channels.HttpRequestChannel.BeginRequest (System.ServiceModel.Channels.Message message, TimeSpan timeout, System.AsyncCallback callback, System.Object state) [0x00012] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:278 
  at System.ServiceModel.Channels.HttpRequestChannel.Request (System.ServiceModel.Channels.Message message, TimeSpan timeout) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:63 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:562 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00066] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:517 
  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 Miguel de Icaza [MSFT] 2011-08-05 17:18:02 UTC
I tried both test cases from that bug, and neither one failed with 2.10.3
Comment 2 Jean-Philippe Leclerc 2011-08-08 08:55:18 UTC
I'm getting this call stack in monotouch when sending an IEnumerable to the wcf service.
Comment 3 Sebastien Pouliot 2011-08-08 11:38:42 UTC
Your original comment was a bit confusing since you only talked about Mono and 2.10.3.

Fixes made to Mono 2.10.x are merged, from time to time, into the tree from which MonoTouch (and Mono for Android) are being built. However updating your Mono version (e.g. to 2.10.3) will not fix any bug in MonoTouch (nor Mono for Android).

AFAICT the patch (from the bug report you linked) is now in monotouch tree so this should be part of the next release (4.1). However if you want to be 100% certain the fix (to your issue, not the bug report) will work then you should attach a test case and state which version of MonoTouch you're currently using - then we'll be able to confirm the fix.
Comment 4 Sebastien Pouliot 2011-08-09 15:04:59 UTC
The test case from #688414 (comment #1) works on MonoTouch (4.1) and a variation using System.Int32[] works too, i.e.

           var ds = new DataContractSerializer (typeof (IEnumerable<int>));
            using (var xw = XmlWriter.Create (Console.Out))
            	ds.WriteObject (xw, new int [] { 1, 2, 3 });

Please re-open the bug, with a self-contained test case, if you still have issues with (the soon to be available) 4.1.