Bug 8533 - System.Configuration.ApplicationSettingsBase screws user.config file when used by multiple child classes
Summary: System.Configuration.ApplicationSettingsBase screws user.config file when use...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Configuration ()
Version: master
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-11-20 22:13 UTC by Kei Nakazawa
Modified: 2012-11-27 05:53 UTC (History)
2 users (show)

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

see "description" for detail (1.46 KB, application/zip)
2012-11-20 22:13 UTC, Kei Nakazawa
fix bug 8533 (6.11 KB, patch)
2012-11-27 04:11 UTC, Kei Nakazawa

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.

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.

Related Links:

Description Kei Nakazawa 2012-11-20 22:13:24 UTC
Created attachment 2981 [details]
see "description" for detail

repro. code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace ApplicationSettingsBaseBehaviorTest
    class ConfHolder1 : ApplicationSettingsBase {
        public string TestKey1OnHolder1 { get { return (string)this["TestKey1OnHolder1"] ?? ""; } set { this["TestKey1OnHolder1"] = value; } }
    class ConfHolder2 : ApplicationSettingsBase
        public string TestKey1OnHolder2 { get { return (string)this["TestKey1OnHolder2"] ?? ""; } set { this["TestKey1OnHolder2"] = value; } }
    class Program
        static void Main(string[] args)
            var holder1 = new ConfHolder1();
            var holder2 = new ConfHolder2();
            holder1.TestKey1OnHolder1 = "candy";
            holder2.TestKey1OnHolder2 = "donut";

multi sectioned XML should be generated by this code like MS runtime does, but Mono(tested on 3.0.0beta/master:5d436f92c) runtime
 - properly generates "sectionGroup" node
 - doesn't generate "section" node for ConfHandler2 inside "sectionGroup"
 - doesn't generate proper node for ConfHandler2 inside "userSettings"
 - put all values together into ConfHolder1 space inside "userSettings", which should be splited into ConfHolder1 subsection and ConfHolder2 subsection (*1: please refer XML snippet below)

I suspect https://bugzilla.xamarin.com/show_bug.cgi?id=2673 report is triggered by this behavior(wrong save -> internal error on next load).

*1: XML snippet
 [MS runtime]
            <setting name="TestKey1OnHolder2" serializeAs="String">
            <setting name="TestKey1OnHolder1" serializeAs="String">
 [/MS runtime]
 [Mono runtime]
  <setting name="TestKey1OnHolder1" serializeAs="String">
  <setting name="TestKey1OnHolder2" serializeAs="String">
 [/Mono runtime]

attached zip contains:
 - Program.cs : repro code(as seen above)
 - user.config.ms : proper user.config file generated by MS runtime(.NET 4.0)
 - user.config.mono : wrong user.config file generated by Mono runtime(master:5d436f92c)
Comment 1 Kei Nakazawa 2012-11-27 04:11:17 UTC
Created attachment 3019 [details]
fix bug 8533

this patch contains
 * test cases for regression testing
 * fix handling multiple userSections creation
 * suppress mixing up other userSections' data

generated against master/2ce79959
Comment 2 Atsushi Eno 2012-11-27 05:53:33 UTC
Thanks, applied this patch too.

[master 05d46a8]