[Mono-bugs] [Bug 48287][Cri] New - class ConfigurationSettings crashes when using nested custom settings in web.config

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 9 Sep 2003 08:02:09 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by michael.paul@tao.es.

http://bugzilla.ximian.com/show_bug.cgi?id=48287

--- shadow/48287	2003-09-09 08:02:09.000000000 -0400
+++ shadow/48287.tmp.11130	2003-09-09 08:02:09.000000000 -0400
@@ -0,0 +1,148 @@
+Bug#: 48287
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Critical
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: michael.paul@tao.es               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: class ConfigurationSettings crashes when using nested custom settings in web.config
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+
+Steps to reproduce the problem:
+1. 
+create a custom web.config:
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+	<configSections>
+		<sectionGroup name="TAO">
+			<sectionGroup name="Buronet">
+				<section name="ConfigSettings" 
+type="System.Configuration.NameValueSectionHandler,System" />
+			</sectionGroup>
+		</sectionGroup>
+	</configSections>	
+  <TAO>
+    <Buronet>
+      <ConfigSettings>
+        <!-- Directory and name where the TaoConfig file is  -->
+        <add key="PATH" value="/usr/local/MyConfig.xml"></add>
+      </ConfigSettings>
+    </Buronet>
+  </TAO>
+</configuration>
+
+2. 
+create a test aspx page:
+<html>
+<body>
+<%
+    NameValueCollection nvc = (NameValueCollection)
+ConfigurationSettings.GetConfig ("TAO/Buronet/ConfigSettings");
+	String s = null;
+    if (nvc != null) {
+		s = nvc["Path"];
+	}
+    Response.Write (s);
+%>
+
+3. 
+custom code which loads the web.config as XMLDocument and does not crash 
+(may it helps to fix this bug):
+<pre>
+static public string GetValue(string section, string key, string 
+defaultValue)
+    {
+
+#if (!mono)
+
+                        NameValueCollection nvc = (NameValueCollection)
+ConfigurationSettings.GetConfig ("TAO/"+ section);
+
+                        String s = null;
+
+                        if (nvc != null) {
+
+                                    s = nvc[key];
+
+                        }
+
+                        return (s==null)? defaultValue:(s);
+
+#else
+
+                        try
+
+                        {
+
+                                    String url = 
+AppDomain.CurrentDomain.GetData("APP_CONFIG_FILE") as String;
+
+                                    System.Xml.XmlDocument oDoc = new 
+System.Xml.XmlDocument();
+
+                                    oDoc.Load (url);
+
+                                    System.Xml.XmlNode oRoot = 
+oDoc.SelectSingleNode (“configuration/TAO/”+ section);
+
+                                    System.Xml.XmlNodeList oLst = 
+oRoot.ChildNodes;
+
+                                    foreach (System.Xml.XmlNode oNode in 
+oLst)
+
+                                    {
+
+                                                if (oNode.Name == "add" && 
+oNode.Attributes["key"] != null)
+
+                                                {
+
+                                                            if 
+(oNode.Attributes["key"].Value.ToUpper () == key.ToUpper())
+
+                                                                        if 
+(oNode.Attributes["value"] != null)
+
+                                                                           
+         return oNode.Attributes["value"].Value;
+
+                                                }
+
+                                    }
+
+                                    return defaultValue;
+
+                        } 
+
+                        catch {return defaultValue;}
+
+#endif
+
+            }
+
+</pre>
+
+Actual Results:
+system crashes: There was no XML start tag open.
+
+Expected Results:
+must not crash, access to configuration settings is critical.
+
+How often does this happen? 
+ALWAYS
+
+Additional Information: