Bug 39669

Summary: System.Configuration.DictionarySectionHandler is missing
Product: [Mono] Class Libraries Reporter: Yvonne Du <duyingfang>
Component: SystemAssignee: Andi McClure <andi.mcclure>
Status: VERIFIED FIXED    
Severity: normal CC: andi.mcclure, chris.hamons, haidary, jachung, mono-bugs+monomac, mono-bugs+mono, peter.collins, shrutis
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: (C7SR1)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Sample project that repros the issue
.NET Console Repro

Description Yvonne Du 2016-03-15 21:19:02 UTC

    
Comment 1 Yvonne Du 2016-03-15 21:19:38 UTC
Once support System.Configuration, please verify that DictionarySectionHandler is included.
Comment 2 Chris Hamons 2016-03-16 14:17:15 UTC
Elements of System.Configuration, can be found in the XM 4.5 Target Framework (along with the system mono target framework). You can read about it here:

https://developer.xamarin.com/guides/mac/advanced_topics/target-framework/

In the future please consider posting questions like this to the forums https://forums.xamarin.com/categories/mac or contact support if you have a business  license (http://xamarin.com/support).
Comment 3 Haidar 2016-04-12 23:53:20 UTC
This is still not resolved.

Here is the exception that we get when using the DictionarySectionHandler. The error that we see is "System.NotImplementedException: The method operation is not implemented". I have attached a sample project that repros this error.

System.Configuration.ConfigurationErrorsException: Type 'System.Configuration.DictionarySectionHandler' not found.
  at System.Configuration.InternalConfigurationHost.GetConfigType (System.String typeName, Boolean throwOnError) [0x00019] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/InternalConfigurationHost.cs:73
  at System.Configuration.ConfigInfo.CreateInstance () [0x00011] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigInfo.cs:50
  at System.Configuration.SectionInfo.CreateInstance () [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/SectionInfo.cs:63
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00022] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:281
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00032] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationSectionCollection.cs:68
  at System.Configuration.Configuration.GetSection (System.String path) [0x0001b] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/Configuration.cs:254
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/ClientConfigurationSystem.cs:61
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.2.1/src/mono/mcs/class/System.Configuration/System.Configuration/ConfigurationManager.cs:159
  at DictionarySample.ViewController.TestBtn (Foundation.NSObject sender) [0x00006] in /Users/haidary/Projects/DictionarySample/DictionarySample/ViewController.cs:37
  at at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
  at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/3052/75f26b5f/source/maccore/src/AppKit/NSApplication.cs:94
  at DictionarySample.MainClass.Main (System.String[] args) [0x00007] in /Users/haidary/Projects/DictionarySample/DictionarySample/Main.cs:10
Comment 4 Haidar 2016-04-12 23:54:06 UTC
Created attachment 15687 [details]
Sample project that repros the issue
Comment 5 Yvonne Du 2016-04-12 23:55:55 UTC
As we still can repro this. See Haidar's sample project.
Comment 6 Chris Hamons 2016-04-14 14:38:43 UTC
Created attachment 15722 [details]
.NET Console Repro
Comment 7 Chris Hamons 2016-04-14 14:40:21 UTC
This appears to be a mono issue. I can reproduce with this example in a .NET console app.

		public static void Main (string[] args)
		{
			System.Configuration.DictionarySectionHandler h = new System.Configuration.DictionarySectionHandler ();
			var type = Type.GetType ("System.Configuration.DictionarySectionHandler");
			Console.WriteLine (h != null);
			Console.WriteLine (type != null);

			Hashtable myCustomSection = (Hashtable)System.Configuration.ConfigurationManager.GetSection ("MyCustomSection");
			Console.WriteLine ("Passed GetSection");
		}

This does not use Xamarin.Mac at all. We are including System.Configuration.DictionarySectionHandler in our assembly. However, in the mono code:

https://github.com/mono/mono/blob/master/mcs/class/System.Configuration/System.Configuration/InternalConfigurationHost.cs#L71

We're calling GetType without specifying an assembly. Since DictionarySectionHandler actually lives in the System assembly currently, it never finds it.
Comment 8 Andi McClure 2016-04-14 18:57:24 UTC
Testing on master this program works, assuming this is correct output:

True
False
Passed GetSection

Looks like we just need to backport this functionality to 4.4.
Comment 9 Andi McClure 2016-04-14 19:03:29 UTC
Actually, I do not reproduce the problem on 4.4 either.
Comment 10 Andi McClure 2016-04-14 19:36:59 UTC
With some help from Chris I have found my lack of crash was due to not loading the app.config properly. I'm reproducing on master now.
Comment 11 Andi McClure 2016-04-14 22:06:57 UTC
Candidate fix, does not throw an exception with the test program. https://github.com/mono/mono/pull/2891
Comment 12 Shruti 2016-06-15 08:43:52 UTC
**************************
Reproduce Status:
**************************
I am able to reproduce this issue with Mono 4.4.0182 for .NET applicaton and XM 
2.8.0.323 for attached XM sample project. I am getting "Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Type System.Configuration.DictionarySectionHandler' not found" for both of the projects.

Error Log: https://gist.github.com/shrutis360/fa8e7dbc0092130ddbeccdef94322e65
Environment Info: https://gist.github.com/shrutis360/fab95e51b451a0bd55308469e02024e7
Screencast: http://www.screencast.com/t/Y1OvvRDWZeP

**************************
Verify Status (with master builds)
**************************
I have verified this issue using master mono 4.5.2.214 for .Net console project and 
XM 

This issue is working fine with Master Mono 4.5.2.214 + master XM 9.9.0.279 for attached sample project. Now I am not getting Unhandled Exception.

Screencast: http://www.screencast.com/t/WyZ5ZoWBZyeY
http://www.screencast.com/t/TOug2dxit
Environment Info: https://gist.github.com/shrutis360/8220443bd280945310b374b5f047661d


Please change the status of the bug.So that I can close it once It get fixed on Release branch.
Comment 13 Chris Hamons 2016-06-15 13:18:59 UTC
QA is correct - "marek-safar merged commit 26b4a3d into mono:master on Apr 20"

Moving bug to resolved:fixed.
Comment 14 Shruti 2016-06-17 07:14:39 UTC
I have checked this issue on C7SR0 MonoFramework-MDK-4.4.0.186.macos10.xamarin.universal_592dc85a3052fd4c30d6dcfce5efe5b62641909c and still getting this issue. 
Screencast: http://www.screencast.com/t/2se7vg9bk8
Console Error log: https://gist.github.com/shrutis360/5efd89257543e7cea2f999f6be0f7348

The trello card related to this issue is kept in ''Merged Patch' which means this issue is fixed on C7SRO lane.

Can you please confirm it. Being now I am re-opening this issue as per trello card status.
Comment 15 Chris Hamons 2016-06-17 15:06:46 UTC
There was an issue where we had multiple builds running around w\ the same version number due to somebody forgetting to bump when we branched.

Can you install the latest SR0 for XM and try again. I've verified the fix should be in there.
Comment 16 Chris Hamons 2016-06-17 20:21:29 UTC
@Andi - So it turn out the fix only appears to fix one of the two samples (DictionarySample works, but TestSystemConfig does not).

Could you take a look and see what additional fixes we need for that?
Comment 17 Shruti 2016-06-20 05:41:02 UTC
Mac Dictionary Sample attached in the project is working fine with C7SR0 XM 2.8.1.3. 
Hence, Xam.Mac issue is fixed.

Note: We need to check .Net Console Repro project with Mono fix before closing this issue.
Comment 18 Andi McClure 2016-06-20 22:10:15 UTC
I'm sorry, I'm confused by the crosstalk on this bug.

Can you please confirm
1. Whether there is an extant bug
2. Exactly what test case the bug appears on (TestSystemConfig.zip?) and on what version of Mono.
Comment 19 Andi McClure 2016-06-20 22:14:46 UTC
Also, checking, the patch containing the fix was merged into master at the time, and is present in 4.5.1, but was never backported into any 4.4 branch. So I would expect the test to succeed on 4.5.1 but fail on current C7SRO.
Comment 20 Chris Hamons 2016-06-21 13:32:25 UTC
@Andi - There are two bug repro attached to this bug:

TestSystemConfig and DirectorySample. 

This commit https://github.com/mono/mono/commit/26b4a3d856d55b7ac2148bccaec298c5c720992c only fixed one of them to work when I tested it. The other still throws an exception.

Please try both attached samples, and see if you can reproduce the issue.
Comment 21 Peter Collins 2016-06-21 18:35:42 UTC
Moving this now to C7SR1 to track the remaining failure case in the ".NET Console Repro" attachment.
Comment 22 Andi McClure 2016-06-22 16:55:02 UTC
I built a version of 4.4.1 amended with the PR2891 patches and attempted to reproduce this bug. Here is what I found.

1. The two sample code packages are identical. The code is identical and the config file is identical. There is no reason why they would behave differently.
2. However, TestSystemConfig is built with Xamarin.Mac and DirectorySample is not.
3. In my testing, TestSystemConfig fails. However, when it fails, the error message clearly indicates it is using the System.Configuration.dll from Xamarin.Mac, *not* from Mono.

Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Type 'System.Configuration.DictionarySectionHandler' not found.
  at System.Configuration.InternalConfigurationHost.GetConfigType (System.String typeName, System.Boolean throwOnError) [0x0002f] in /Library/Frameworks/Xamarin.Mac.framework/Versions/2.9.0.719/src/mono/mcs/class/System.Configuration/System.Configuration/InternalConfigurationHost.cs:74 

The fix for this bug is in System.Configuration.dll.

I believe that the problem is indeed already fixed, and that we are seeing failures because we are setting up the test wrong (by using Xamarin.Mac which substitutes an older System.Configuration.dll). The thing to do to verify TestSystemConfig works is to wait until a Xamarin.Mac is built on top of a mono containing this fix, and then test with that Xamarin.Mac.

Here is a pull request which we can use to merge this fix into C7SR1 once that has a branch. https://github.com/mono/mono/pull/3196
Comment 23 Peter Collins 2016-06-22 17:27:36 UTC
Resolving as per Comment #22.
Comment 24 Peter Collins 2016-06-22 17:28:08 UTC
Both the 'DirectorySample' and 'TestSystemConfig' test cases no longer throw this exception when using XM 2.8.1.3 (c7sr0/422d7d4) and mono-4.4.0-branch/ff15b4214 respectively.
Comment 25 Chris Hamons 2016-06-24 01:08:31 UTC
@Andi - Thanks! Sorry for the trouble.