Bug 36401 - [XM 2.4] "System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer" when using ChannelFactory with the "Xamarin.Mac .NET 4.5 Framework"
Summary: [XM 2.4] "System.Configuration.ConfigurationErrorsException: Failed to load c...
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other (show other bugs)
Version: 2.4.0 (C6)
Hardware: PC Mac OS
: High blocker
Target Milestone: master
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-11-30 23:00 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-09-16 15:10 UTC (History)
6 users (show)

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


Attachments
Test case (349.15 KB, application/zip)
2015-11-30 23:00 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Diagnostic build output and version info (31.63 KB, application/zip)
2015-11-30 23:02 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-11-30 23:00:46 UTC
Created attachment 14046 [details]
Test case

[XM 2.4] "System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer" when using ChannelFactory with the "Xamarin.Mac .NET 4.5 Framework"




## Regression status: effectively a regression in Xamarin.Mac 2.4

BAD:  Xamarin.Mac 2.4.0.109 (815e5d6)
GOOD: Xamarin.Mac 2.0.2.111 (6db87c5)


The regression status might be slightly "special" because I think this new error might be caused by a "new feature" in Xamarin.Mac 2.4 where "System.Configuration" is more intentionally excluded from the "Xamarin.Mac .NET 4.5 Framework" profile.




## Steps to reproduce

1. Build the attached test case in the Debug configuration:
> $ xbuild /t:Build MacWCFClient.sln

2. Run the compiled binary on the command line:
> $ MacWCFTest/bin/Debug/MacWCFTest.app/Contents/MacOS/MacWCFTest




## Results

The WCF request fails because the program tries to use "System.Configuration" and "System.Configuration" is not included in the "Xamarin.Mac .NET 4.5 Framework" profile.

### Output of the program from standard output and standard error

> Sent request...
> 2015-11-30 17:10:06.840 MacWCFTest[8139:139662] 
> Unhandled Exception:
> System.Configuration.ConfigurationErrorsException: Failed to load configuration section for dataContractSerializer.
>   at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
>   at (wrapper remoting-invoke) TempConvertSoap:EndFahrenheitToCelsius (System.IAsyncResult)
>   at MacWCFTest.ViewController.OnTestMethodCompleted (IAsyncResult asyncResult) [0x0000d] in /private/tmp/Working/MacWCFTest/MacWCFTest/ViewController.cs:49 




## Possible workaround that was observed to stop the problem


1. Navigate to "Project Options -> General".


2. Change the "Target Framework" to either:

(a) "Xamarin.Mac Mobile Framework"

or 

(b) "Unsupported Framework: Mono / .NET 4.5"

(See also http://developer.xamarin.com/guides/mac/advanced_topics/target-framework/)




## Why this is not expected behavior

At first I thought this unhandled exception might be the correct, expected behavior because the "Xamarin.Mac .NET 4.5 Framework" is explicitly documented not to include "System.Configuration" [1]. The problem with that theory is that the "Xamarin.Mac Mobile Framework" _does_ work correctly in this test case. I would expect the "Xamarin.Mac .NET 4.5 Framework" to include all of the functionality (i.e., be a superset) of the "Xamarin.Mac Mobile Framework".

[1] "The Xamarin.Mac .NET 4.5 Framework ... is missing large, rarely used elements, such as System.Configuration"
> http://developer.xamarin.com/guides/mac/advanced_topics/assemblies/#The_Xamarin.Mac_.NET_4.5_Framework


It seems like maybe the problem is that the "Xamarin.Mac .NET 4.5 Framework" still includes some "vestigial" piece of System.Configuration that needs to be _removed_. For example...


### When built with the "Xamarin.Mac .NET 4.5 Framework", the `MonoBundle/` folder _does_ include `System.Configuration.dll`

> $ ls MacWCFTest/bin/Debug/MacWCFTest.app/Contents/MonoBundle/System.Configuration.dll
> MacWCFTest/bin/Debug/MacWCFTest.app/Contents/MonoBundle/System.Configuration.dll


### When built with the "Xamarin.Mac Mobile Framework", the `MonoBundle/` folder does _not_ include `System.Configuration.dll`

> $ ls MacWCFTest/bin/Debug/MacWCFTest.app/Contents/MonoBundle/System.Configuration.dll
> ls: MacWCFTest/bin/Debug/MacWCFTest.app/Contents/MonoBundle/System.Configuration.dll: No such file or directory
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-11-30 23:02:19 UTC
Created attachment 14047 [details]
Diagnostic build output and version info
Comment 10 Chris Hamons 2016-01-26 22:34:13 UTC
So my analysis was wrong. This turns out to be significantly more straightforward than expected.

Working on a fix now. Support contacts will reach out to customer w/ build to test.
Comment 11 Bruce McNeish 2016-01-27 10:52:46 UTC
Hey Chris,

I have hit this issue also and would be interested in testing any fix you may have, if possible?

Thanks.
Comment 12 Chris Hamons 2016-01-27 15:57:12 UTC
Fixed in master/maccore. Will make C7 release. A build is out to the reporter w/ fix for testing.

@Bruce - I will contact you directly to discuss.
Comment 14 Chris Hamons 2016-09-16 15:10:26 UTC
This is completely unrelated. This stack trace:

Parameter name: typeArguments
  at (wrapper managed-to-native) System.RuntimeType:MakeGenericType (System.Type,System.Type[])
  at System.RuntimeType.MakeGenericType (System.Type[] instantiation) [0x000ef] in /Library/Frameworks/Xamarin.Mac.framework/Versions/3.1.0.28/src/mono/mcs/class/referencesource/mscorlib/system/rttype.cs:4272 
  at Registrar.DynamicRegistrar.VerifyIsConstrainedToNSObject (System.Type type, System.Type& constrained_type) [0x000ce] in /Users/builder/data/lanes/1381/4a87ccf9/source/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:473 
  at Registrar.Registrar.VerifyIsConstrainedToNSObject (System.Collections.Generic.List`1[System.Exception]& exceptions, System.Type type, Registrar.Registrar+ObjCMethod method) [0x0000c] in /Users/builder/data/lanes/1381/4a87ccf9/source/xamarin-macios/src/ObjCRuntime/Registrar.cs:1178 
  at Registrar.Registrar.RegisterTypeUnsafe (System.Type type, System.Collections.Generic.List`1[System.Exception]& exceptions) [0x00fba] in /Users/builder/data/lanes/1381/4a87ccf9/source/xamarin-macios/src/ObjCRuntime/Registrar.cs:1819 
  at Registrar.Registrar.RegisterAssembly (System.Reflection.Assembly assembly) [0x000b0] in /Users/builder/data/lanes/1381/4a87ccf9/source/xamarin-macios/src/ObjCRuntime/Registrar.cs:1933 

is this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=44309

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.


Create a new report for Bug 36401 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments


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.

Related Links: