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 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.
Created attachment 2344 [details]
When using DataContractSerializer sometimes the XML tags outputted may contain "d2p1" namespaces.
To workaround this problem in theory the attribute [DataContract(Namespace = "")] can be used in the class.
This works in MS.NET but not on Mono.
Attaching testcase (just build with xbuild* and run with nunit-console, which in my system defaults to 18.104.22.168 in the 4.0 runtime).
*Or use the DLLs provided in the compressed attachment inside bin/Debug.
Current results: 1 test fails, 2 pass
Expected results (MS.NET): 3 tests pass
So it turns out the bug is not actually inside the class libraries:
My testcase contains 2 assemblies; one of them is compiled with TargetFramework=3.5 and the other 4.0. As soon as you change them (their .csprojs) to use the same version of the framework (both 3.5 or both 3.5), the bug disappears.
And this happens because the class that contains the [DataContract] attribute targets framework 4.0, but the call to the ctor of DataContractSerializer happens in the assembly that references framework 3.5, then the call for Type.GetCustomAttributes(T) fails because T is typeof(DataContractAttribute), v22.214.171.124, not 126.96.36.199.
But Microsoft.NET doesn't have this bug even in machines with more than one version of the runtime.
I think I'll post an email in the mono-devel mailing list about this interesting finding.
typo: s/both 3.5 or both 3.5/both 3.5 or both 4.0/
BTW I posted about this in mono-devel: http://lists.ximian.com/pipermail/mono-devel-list/2012-October/039675.html
The fix for #8037 fixes this as well, so it is effectively the same bug.
*** This bug has been marked as a duplicate of bug 8037 ***