Bug 6913 - Error creating XmlSerializer on mono (on .NET is ok) when target's parent[!] class don't have parameterless constructor
Summary: Error creating XmlSerializer on mono (on .NET is ok) when target's parent[!] ...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 2.10.x
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2012-09-05 09:27 UTC by Stanislav
Modified: 2014-09-23 12:05 UTC (History)
3 users (show)

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


Attachments
on .Net will output success in console, on mono - exception. (3.35 KB, text/plain)
2012-09-05 09:27 UTC, Stanislav
Details
on .Net will output success in console, on mono - exception. (2.98 KB, text/plain)
2012-09-05 09:40 UTC, Stanislav
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 Stanislav 2012-09-05 09:27:01 UTC
Created attachment 2460 [details]
on .Net will output success in console, on mono - exception.

Demo sample in attachment (console program)

on mono version's 2.10.9 and 2.10.8 this bug is present (tested). On MS .net works fine.

When creating new "new XmlSerializer()" for some target class (A) inherited from class without parameterless constructor (B) - have exception.

exception example:

System.InvalidOperationException: There was an error reflecting type 'MonoXmlSerializerBug.SearchOrTeachCalloutData'.   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00174] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:241 
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0003c] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:196 
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00047] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:227 
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in <filename unknown>:0 
  at MonoXmlSerializerBug.Program.SerializeToString (System.Object o) [0x0000d] in /Users/master/Documents/MonoXmlSerializerBug/MonoXmlSerializerBug/Program.cs:40 
  at MonoXmlSerializerBug.Program.Main (System.String[] args) [0x00006] in /Users/master/Documents/MonoXmlSerializerBug/MonoXmlSerializerBug/Program.cs:16 
Inner exception: MonoXmlSerializerBug.BaseTeachCalloutData cannot be serialized because it does not have a default public constructor   at System.Xml.Serialization.ReflectionHelper.CheckSerializableType (System.Type type, Boolean allowPrivateConstructors) [0x000cd] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/ReflectionHelper.cs:101 
  at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00030] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:336 
  at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00007] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:325 
  at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x001cd] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:368 
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0006e] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:221
Comment 1 Stanislav 2012-09-05 09:40:50 UTC
Created attachment 2461 [details]
on .Net will output success in console, on mono - exception.
Comment 2 marcos.henrich 2014-08-18 10:38:51 UTC
Hi Stanislav,

Thank you for the detailed bug report.

The pull request for this issue can be found in the link below.
https://github.com/mono/mono/pull/1214/files
Comment 3 marcos.henrich 2014-08-19 02:38:21 UTC
Fixed in master 580902813576ad54d70b1629ac8e4278de692aa5.
Comment 4 Udham Singh 2014-09-23 12:05:21 UTC
I have checked this issue with builds XS 4.0.5.4-1 and Mono 2.10.11, and able to reproduce this issue  with these builds.

Console output (or Exception log) with builds XS 4.0.5.4-1 and Mono 2.10.11 : https://gist.github.com/Udham1/bb5a28f95b150e61b781

I have also checked this issue with builds XS 5.5 (build 204) and Mono 3.10.0.16, and it is working fine with builds XS 5.5 (build 204) and Mono 3.10.0.16, Hence closing this issue.

Screencast : http://screencast.com/t/PWxxVv57za

Environment Info :

=== Xamarin Studio ===

Version 5.5 (build 204)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 3.10.0 ((detached/ac51002)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000016

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===

Version: 8.2.0.177 (Business Edition)
Hash: 3b73f2a
Branch: 
Build date: 2014-09-19 00:21:20-0400

=== Xamarin.Mac ===

Version: 1.11.0.1 (Business Edition)

=== Xamarin.Android ===

Version: 4.18.0.32 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.0    (API level 11)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		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)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Build Information ===

Release ID: 505000204
Git revision: 2affa3acc16487d4f8fb5cb33c49e2423469091e
Build date: 2014-09-23 07:14:56-04
Xamarin addins: c31fea2f959659225466adef1c0793a8d7eebcef

=== Operating System ===

Mac OS X 10.9.4
Darwin Xamarin76s-Mac-mini.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64