Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 for Bug 249 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 102 [details]
VS2010 Projects and source
Here is the scenario:
SerializeLib.dll is compiled against .NET 3.5 Framework. It provides 2 methods:
string Serialize(object data) // uses DataContractSerializer to serialize to xml
object Deserialize(string xml, Type t) // uses DataContractSerializer to deserialize from xml.
Program.exe is compiled against .NET 4.0 Framework.
It creates a simple class where it uses [IgnoreDataMember] attribute to mark certain properties for exclusion when serialized.
It has another class which has the [DataContract] attribute. This class is missing the [DataMember] attribute from one of its properties so that the property will be excluded.
The [IgnoreDataMember] attribute is not honored and the properties with this attribute are serialized when they should not be when I use the methods defined in SerializeLib.dll to perform the work.
And the class with the [DataContract] serializes all properties even those missing the [DataMember] attribute.
If I recompile SeralizeLib.dll using the .NET Framework 4.0, then the problem goes away.
Microsoft's .NET runtime does not have this issue. The program works correctly if SerializeLib.dll is compiled against 3.5 or 4.0.
You can use the attached VS2010 projects to compile the bits, or you can compile them on mono with:
gmcs -out:SerializeLib.dll -target:library -r:System.Runtime.Serialization MyXmlSerializer.cs
dmcs -out:Program.exe Program.cs -r:SerializeLib.dll,System.Runtime.Serialization
mono --runtime=v4.0.30319 Program.exe
This will produce exceptions when the program sees that the deserialized object has values for the properties in question.
Recompiling SerializeLib.dll with "dmcs" so that it targets .NET 4.0 and then rerun Program.exe and everything works without error.
mono -- version:
Mono JIT compiler version 2.10.3 (tarball Mon Aug 8 13:48:37 CDT 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
-> class libs.