2007-05-14 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 14 May 2007 10:05:15 +0000 (10:05 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 14 May 2007 10:05:15 +0000 (10:05 -0000)
* ConfigurationElement.cs: when attribute value cannot be parsed,
ConfigurationErrorException is thrown.

svn path=/trunk/mcs/; revision=77338

mcs/class/System.Configuration/System.Configuration/ChangeLog
mcs/class/System.Configuration/System.Configuration/ConfigurationElement.cs

index 884744a2be32947e953c285490d37d938274d503..2d59de6392adda00cf0c52fa1f19de24f0f4beaf 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-14 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ConfigurationElement.cs: when attribute value cannot be parsed,
+       ConfigurationErrorException is thrown.
+               
 2007-05-09 Igor Zelmanovich <igorz@mainsoft.com>
 
        * ConfigurationManager.cs:
index 0228717eb356b63ce47e7f520ba07bcb9f54d75f..428d74d42113f50b2033720c16a47bac5296ef16 100644 (file)
@@ -296,7 +296,7 @@ namespace System.Configuration
                                        else if (reader.LocalName == "lockElements") {
                                                LockElements.SetFromList (reader.Value);
                                        }
-                                       else if (reader.LocalName == "lockItem") {\r
+                                       else if (reader.LocalName == "lockItem") {
                                                LockItem = (reader.Value.ToLowerInvariant () == "true");
                                        }
                                        else if (reader.LocalName == "xmlns") {
@@ -311,7 +311,13 @@ namespace System.Configuration
                                if (readProps.ContainsKey (prop))
                                        throw new ConfigurationException ("The attribute '" + prop.Name + "' may only appear once in this element.");
                                
-                               prop.SetStringValue (reader.Value);
+                               try {
+                                       prop.SetStringValue (reader.Value);
+                               }
+                               catch (Exception ex) {
+                                       string msg = String.Format ("The value of the property '{0}' cannot be parsed.", prop.Name);
+                                       throw new ConfigurationErrorsException (msg, reader);
+                               }
                                readProps [prop] = prop.Name;
                        }