Bug 38064

Summary: DataContractJsonSerializer does not work under the "supported" 4.5 profile
Product: [Desktop] Xamarin.Mac Reporter: Aaron Bockover [MSFT] <abock>
Component: Base Class LibrariesAssignee: Chris Hamons <chris.hamons>
Status: VERIFIED FIXED    
Severity: normal CC: abock, mono-bugs+monomac, pj.beaman, rolf, sebastien, shrutis
Priority: High    
Version: 2.4.1 (C6SR1)   
Target Milestone: 2.8.0 (C7)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Aaron Bockover [MSFT] 2016-01-26 17:47:11 UTC
Possibly due to switching to MS' reference source, the DataContractJsonSerializer no longer works under the full (supported) XM 4.5 profile. It *does* work as expected under the mobile profile.

This looks like RS is trying to use System.Configuration to load dependencies of the JSON serializer, which (at least previously in Mono) was fully contained in the System.Runtime.Serialization assembly.

The test is very simple:

	[DataContract]
	public class SomeContract
	{
	}

	void GoBoomBoom ()
	{
		new DataContractJsonSerializer (typeof(SomeContract))
			.WriteObject (new MemoryStream (), new SomeContract ());
	}

The following exception is the result on full 4.5:

System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer.
  at System.Runtime.Serialization.Configuration.DataContractSerializerSection.UnsafeGetSection () [0x00016] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Configuration/DataContractSerializerSection.cs:30
  at System.Runtime.Serialization.DataContract.get_ConfigSection () [0x0000a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs:1999
  at System.Runtime.Serialization.DataContract.LoadKnownTypesFromConfig (System.Type type, System.Collections.Generic.Dictionary`2 typesChecked, System.Collections.Generic.Dictionary`2& knownDataContracts) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs:2106
  at System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes (System.Type type, System.Collections.Generic.Dictionary`2 typesChecked, System.Collections.Generic.Dictionary`2& knownDataContracts) [0x00256] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs:2087
  at System.Runtime.Serialization.DataContract.ImportKnownTypeAttributes (System.Type type) [0x00008] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/DataContract.cs:2009
  at System.Runtime.Serialization.ClassDataContract+ClassDataContractCriticalHelper.get_KnownDataContracts () [0x00033] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs:1269
  at System.Runtime.Serialization.ClassDataContract.get_KnownDataContracts () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs:196
  at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType (System.Runtime.Serialization.DataContract dataContract, System.Runtime.Serialization.XmlWriterDelegator xmlWriter, System.Object obj, RuntimeTypeHandle declaredTypeHandle) [0x0000f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs:150
  at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObjectContent (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph) [0x000ab] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs:476
  at System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalWriteObject (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph) [0x00008] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs:444
  at System.Runtime.Serialization.XmlObjectSerializer.InternalWriteObject (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:112
  at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph, System.Runtime.Serialization.DataContractResolver dataContractResolver) [0x00079] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:82
  at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions (System.Runtime.Serialization.XmlWriterDelegator writer, System.Object graph) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializer.cs:64
  at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs:292
  at System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteObject (System.IO.Stream stream, System.Object graph) [0x00018] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/src/mono/external/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Json/DataContractJsonSerializer.cs:281
  at XMDCSJTest.ViewController.GoBoomBoom (Foundation.NSObject sender) [0x0001a] in /Users/aaron/Projects/XMDCSJTest/ViewController.cs:33
  at at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
  at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/2691/95597048/source/maccore/src/AppKit/NSApplication.cs:94
  at XMDCSJTest.MainClass.Main (System.String[] args) [0x00007] in /Users/aaron/Projects/XMDCSJTest/Main.cs:17
Comment 2 Aaron Bockover [MSFT] 2016-01-26 17:53:49 UTC
Test case: https://github.com/abock/filed-bug-test-cases/tree/master/Xamarin/bxc38064
Comment 3 Chris Hamons 2016-01-27 15:53:49 UTC
Fixed in latest maccore/master. Will make C7.

I have a custom one-off build build for Inspector.
Comment 4 Shruti 2016-05-17 09:20:49 UTC
*******************
Reproduce  Status
********************
I am able to reproduce this issue with attached application and build details.

Application Crash logs: https://gist.github.com/shrutis360/5915ac2527d724a55350176ce31d16ff
Environment Info: https://gist.github.com/


*******************
Verify  Status
********************
It is working fine with latest C7 builds.
Environment Info: https://gist.github.com/shrutis360/e8f0f5b8106ac0d00ae9e63193d0908b


Hence, Closing this issue.