Bug 24413 - DataContractSerializer KnownType not being called in iOS
Summary: DataContractSerializer KnownType not being called in iOS
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.4.0
Hardware: PC Windows
: Normal normal
Target Milestone: 9.2 (C6)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-10 18:12 UTC by Jon Douglas [MSFT]
Modified: 2015-11-16 11:21 UTC (History)
6 users (show)

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


Attachments
Reproduction (41.34 KB, application/x-zip-compressed)
2014-11-10 18:12 UTC, Jon Douglas [MSFT]
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:
VERIFIED FIXED

Description Jon Douglas [MSFT] 2014-11-10 18:12:29 UTC
Created attachment 8683 [details]
Reproduction

Customer Description:

I'm getting an error when using DataContractSerializer (see stack trace below).
It's failing because the KnownType("methodname") is not being called.

at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000c1] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:250
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id, Boolean empty) [0x00223] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292
at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000d3] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:252
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.CollectionTypeMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x0006a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:668
at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000d3] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:252
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id, Boolean empty) [0x00223] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292
at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000d3] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:252
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.CollectionTypeMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x0006a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:668
at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000d3] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:252
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id, Boolean empty) [0x00223] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347
at System.Runtime.Serialization.SerializationMap.DeserializeContent (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer, System.String id) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292
at System.Runtime.Serialization.SerializationMap.DeserializeObject (System.Xml.XmlReader reader, System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264
at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap (System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader reader) [0x000d3] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:252
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Type type, System.Xml.XmlReader reader) [0x00302] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:194
at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Xml.XmlReader reader, System.Type declaredType, System.Runtime.Serialization.KnownTypeCollection knownTypes, IDataContractSurrogate surrogate, System.Runtime.Serialization.DataContractResolver resolver, System.Runtime.Serialization.DataContractResolver defaultResolver, System.String name, System.String ns, Boolean verifyObjectName) [0x0007e] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:65
at System.Runtime.Serialization.DataContractSerializer.ReadObject (System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x00024] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:363
at System.Runtime.Serialization.DataContractSerializer.ReadObject (System.Xml.XmlReader reader, Boolean verifyObjectName) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.15/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:353

See attached zipped solution that reproduce the issue.

There are two applications, iPhone and Store app, both is referencing a core portable class.
Store app run as expected but not iPhone as it throws an exception in the deserialization part.
I put some comments where the possible issue.

When doing this reproduceable solution I found out that when using a different Namespace in DataContract attribute, the deserialization fails.
As I mentioned, we don’t have control to the proxy so we can’t do any changes with them.
Comment 1 Parmendra Kumar 2014-11-11 06:42:02 UTC
I have checked this issue with attached sample project and I am also getting same exception mentioned in the bug description.

Screencast:http://www.screencast.com/t/SY6jO7upd
DebugLog:https://gist.github.com/Parmendrak/3815d033be000fca149e
MtbsLog:https://gist.github.com/Parmendrak/d134ee5a6d21f1062a6e
ZipxamLog:https://gist.github.com/Parmendrak/6e35a78c57f1f3808fd3

Environment Info:
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.7.248.0 
Xamarin.Android   4.18.1.3 
Xamarin.iOS   8.4.0.0
Comment 3 Sebastien Pouliot 2015-10-06 19:54:04 UTC
Not sure why this was put as a NEEDINFO ? seems the attachment was not seen :(

This seems to be working correctly in C6 (where a lot of this code is now the MS RS version) so I'm closing it to let QA verify it.
Comment 4 GouriKumari 2015-11-16 11:21:30 UTC
Verified this issue with XI Version: 9.2.1.51 (Enterprise Edition), Hash: 3c0ec35. I could successfully launch TestApp.iPhone on an iPhone6S, without any exception.

Application Output: https://gist.github.com/GouriKumari/c58d226f444c83397642

Test Env:
=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.iOS ===

Version: 9.2.1.51 (Enterprise Edition)
Hash: 3c0ec35
Branch: master
Build date: 2015-11-12 13:05:39-0500

=== Xamarin.Android ===

Version: 6.0.0.33 (Enterprise Edition)
Android SDK: /Users/gourikumari/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)

SDK Tools Version: 22.6.3
SDK Platform Tools Version: 19.0.2
SDK Build Tools Version: 19.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Version: 2.4.0.109 (Enterprise Edition)

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 06:02:54-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.10.5
Darwin Gouri.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64