Bug 20403 - IOE when XML-serializing System.Drawing.Color
Summary: IOE when XML-serializing System.Drawing.Color
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2014-06-05 17:53 UTC by Jonathan Pryor
Modified: 2014-11-27 04:16 UTC (History)
3 users (show)

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


Attachments
SerializationIssue Example.zip (68.47 KB, application/zip)
2014-06-05 17:53 UTC, Jonathan Pryor
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 GitHub or Developer Community 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 Jonathan Pryor 2014-06-05 17:53:26 UTC
Created attachment 6993 [details]
SerializationIssue Example.zip

Via: http://forums.xamarin.com/discussion/comment/56661/#Comment_56661

Mono doesn't appear to support/use custom XML serializers.

To reproduce:

1. Download the attached SerializationIssue Example.zip.
2. Unzip it.

    $ unzip SerializationIssue\ Example.zip

3. Build the Console project:

    $ ExampleCode/ConsoleTestApp

4. Build it:

    $ rm -Rf bin obj
    $ xbuild

5. Run it:

    $ mono --debug bin/Debug/ConsoleTestApp.exe

Expected results: no error.

Actual results:

> $ mono --debug bin/Debug/ConsoleTestApp.exe
> Build the test object: Name: Test object, Year: 1980, Color: 255, 255, 0, 0
> Serialised as:
> <?xml version="1.0" encoding="utf-16"?>
> <SimpleObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>   <Name>Test object</Name>
>   <YearOfManufacture>1980</YearOfManufacture>
>   <BodyColor />
> </SimpleObject>
> Going to deserialize to a new object.
> Got the new object: Name: Test object, Year: 1980, Color: 0, 0, 0, 0
> 
> Build the test object: Name: Test object, Year: 1980, Color: 255, 255, 0, 0
> An exception occured!:
> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type of the argument object 'System.Drawing.Color' is not primitive.
>   at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive (System.String name, System.String ns, System.Object o, Boolean xsiType) [0x000f4] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs:899 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) [0x0014e] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:135 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x0023e] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:343 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00121] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:265 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x0000c] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:198 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00036] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:186 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) [0x001c4] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:150 
>   at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot (System.Object ob) [0x00056] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:75 
>   at System.Xml.Serialization.XmlSerializer.Serialize (System.Object o, System.Xml.Serialization.XmlSerializationWriter writer) [0x0001c] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:412 
>   at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces) [0x00064] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:480 
>   --- End of inner exception stack trace ---
>   at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces) [0x000a0] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:487 
>   at System.Xml.Serialization.XmlSerializer.Serialize (System.IO.TextWriter textWriter, System.Object o) [0x0000e] in /Volumes/build-root-ramdisk/mono-3.4.0/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:435 
>   at SerializationIssue.SimpleObjectB.Save (SerializationIssue.SimpleObjectB target) [0x00022] in /Users/jon/Downloads/support/ExampleCode/SerializationIssue/StandardDotNetLibrary/SimpleObjectB.cs:24 
>   at ConsoleTestApp.Program.SimpleObjectB () [0x00046] in /Users/jon/Downloads/support/ExampleCode/ConsoleTestApp/Program.cs:60
Comment 1 marcos.henrich 2014-09-10 12:45:37 UTC
Hi Jonathan,

Thanks for the detailed bug report.

The problem was that the used implicit conversions were not supported by XmlSerializer.

The following pull request fixes the issue:
https://github.com/mono/mono/pull/1270
Comment 2 marcos.henrich 2014-09-10 13:12:37 UTC
Fixed in master 156c7cf97a011cfa9dd91d69c22cd060819f8a64.
https://github.com/mono/mono/commit/156c7cf97a011cfa9dd91d69c22cd060819f8a64
Comment 3 Shruti 2014-11-27 04:16:43 UTC
I have checked this issue with downloading attached project and following instructions given in comment(0). I did not experience any issue after running ConsoleTestApp.exe.

Hence, this issue has been fixed.

Here is the screencast regarding same : http://www.screencast.com/t/BD2eWBuu

Environment Info :

=== Xamarin Studio ===

Version 5.7 (build 596)
Installation UUID: 67eaf3b4-f8a7-4ab4-a9df-3197350ca5dc
Runtime:
	Mono 3.12.0 ((detached/b75fa2b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000046

=== Apple Developer Tools ===

Xcode 6.2 (6736)
Build 6C86e

=== Xamarin.iOS ===

Version: 8.6.0.5 (Business Edition)
Hash: 880cc21
Branch: 
Build date: 2014-11-25 12:12:17-0500

=== Xamarin.Android ===

Version: 5.0.0.0 (Business Edition)
Android SDK: /Users/ixamarin78/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0

=== Operating System ===

Mac OS X 10.10.0
Darwin XamnewiMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64