[Mono-bugs] [Bug 418834] ConfigurationErrorsException in app.config parse

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Sep 5 14:44:58 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=418834

User andyhume32 at yahoo.co.uk added comment
https://bugzilla.novell.com/show_bug.cgi?id=418834#c1


Andy Hume <andyhume32 at yahoo.co.uk> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
                 CC|                                                |andyhume32 at yahoo.co.uk




--- Comment #1 from Andy Hume <andyhume32 at yahoo.co.uk>  2008-09-05 12:44:58 MDT ---
I've hit such a couple of times problem previously, and changed the code in
CustomizableFileSettingsProvider.LoadPropertyValue thus:
[[
Index: class/System/System.Configuration/CustomizableFileSettingsProvider.cs
===================================================================
--- class/System/System.Configuration/CustomizableFileSettingsProvider.cs      
(revision 112373)
+++ class/System/System.Configuration/CustomizableFileSettingsProvider.cs      
(working copy)
@@ -694,8 +694,8 @@
                                if (allowOverwrite)
                                        values.Remove (element.Name);
                                values.Add (value);
-                       } catch (ArgumentException) {
-                               throw new ConfigurationErrorsException ();
+                       } catch (ArgumentException ex) {
+                               throw new ConfigurationErrorsException
("bahhhh", ex);
                        }
                }
]]

With that in place the exception is much more useful.  It shows that the
current code can't support options with the same name in two locations.

With your config file (regardless of code??) I see the following, it shows that
"AutoLogin" appears twice in the config file.
[[
Unhandled Exception: System.Configuration.ConfigurationErrorsException: bahhhh
---> System.ArgumentException: Key duplication when adding: AutoLogin
  at System.Collections.Hashtable.PutImpl (System.Object key, System.Object
value, Boolean overwrite) [0x00137] in
D:\cygwin\usr\src\mono\mcs\class\corlib\System.Collections\Hashtable.cs:814 
  at System.Collections.Hashtable.Add (System.Object key, System.Object value)
[0x00000] in
D:\cygwin\usr\src\mono\mcs\class\corlib\System.Collections\Hashtable.cs:459 
  at System.Configuration.SettingsPropertyValueCollection.Add
(System.Configuration.SettingsPropertyValue property) [0x00011] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\SettingsPropertyValueCollection.cs:52 
  at System.Configuration.CustomizableFileSettingsProvider.LoadPropertyValue
(System.Configuration.SettingsPropertyCollection collection,
System.Configuration.SettingElement element, Boolean allowOverwrite) [0x0007c]
in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\CustomizableFileSettingsProvider.cs:696 
  --- End of inner exception stack trace ---
  at System.Configuration.CustomizableFileSettingsProvider.LoadPropertyValue
(System.Configuration.SettingsPropertyCollection collection,
System.Configuration.SettingElement element, Boolean allowOverwrite) [0x0008e]
in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\CustomizableFileSettingsProvider.cs:698 
  at System.Configuration.CustomizableFileSettingsProvider.LoadProperies
(System.Configuration.ExeConfigurationFileMap exeMap,
System.Configuration.SettingsPropertyCollection collection,
ConfigurationUserLevel level, System.String sectionGroupName, Boolean
allowOverwrite) [0x00064] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\CustomizableFileSettingsProvider.cs:712 
  at System.Configuration.CustomizableFileSettingsProvider.GetPropertyValues
(System.Configuration.SettingsContext context,
System.Configuration.SettingsPropertyCollection collection) [0x00030] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\CustomizableFileSettingsProvider.cs:738 
  at System.Configuration.LocalFileSettingsProvider.GetPropertyValues
(System.Configuration.SettingsContext context,
System.Configuration.SettingsPropertyCollection properties) [0x00000] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\LocalFileSettingsProvider.cs:68 
  at System.Configuration.ApplicationSettingsBase.CacheValuesByProvider
(System.Configuration.SettingsProvider provider) [0x00062] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\ApplicationSettingsBase.cs:179 
  at System.Configuration.ApplicationSettingsBase.GetPropertyValue
(System.String propertyName) [0x00042] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\ApplicationSettingsBase.cs:201 
  at System.Configuration.ApplicationSettingsBase.get_Item (System.String
propertyName) [0x00000] in
D:\cygwin\usr\src\mono\mcs\class\System\System.Configuration\ApplicationSettingsBase.cs:209 
  at MyApplication.UI.Properties.Settings.get_Server () [0x00000] 
  at MyApp.UI.AppMainEntry.Main () [0x00000] 
]]


In my case, each time I'd created a second set of configuration items by
mistake in VisualStudio, so I could just delete the duplicate set. 
Hopefully(!) the same is the case in your situation?  If not, you'd need this
fixed...


Someone with commit priv's might want to commit a change like the above anyway
as it makes the root cause clear -- it's better than discarding the initial
exception!


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list