Hello, The attached diff fixes handling for situations where web.config contains code like:
<?xml version="1.0" standalone="yes"?> <configuration> <configSections> <sectionGroup name="system.web"> <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler,Brettle.Web.NeatUpload" allowLocation="true" /> </sectionGroup> </configSections> <system.web> <neatUpload useHttpModule="false" maxNormalRequestLength="4096" maxRequestLength="2097151" defaultProvider="FilesystemUploadStorageProvider"> <providers> <add name="FilesystemUploadStorageProvider" type="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider,Brettle.Web.NeatUpload" tempDirectory="UploadTemp"/> </providers> </neatUpload> </system.web> </configuration> Current implementation of System.Configuration for the 2.0 runtime will throw an exception claiming that the <neatUpload> section is unknown. Configuration code does read the <configSections> but it mistakenly allocates a new system.web section instead of merging it with the existing one. The diff causes the sections to be properly merged and any custom config sections to be recognized. Please, review best regards, marek
Index: SectionInfo.cs =================================================================== --- SectionInfo.cs (revision 68577) +++ SectionInfo.cs (working copy) @@ -207,6 +207,9 @@ tr.Close ();*/ } } + + internal override void Merge (ConfigInfo data) + {} } } Index: ConfigInfo.cs =================================================================== --- ConfigInfo.cs (revision 68577) +++ ConfigInfo.cs (working copy) @@ -80,6 +80,8 @@ public abstract void WriteConfig (Configuration cfg, XmlWriter writer, ConfigurationSaveMode mode); public abstract void ReadData (Configuration config, XmlTextReader reader, bool overrideAllowed); public abstract void WriteData (Configuration config, XmlWriter writer, ConfigurationSaveMode mode); + + internal abstract void Merge (ConfigInfo data); } } Index: SectionGroupInfo.cs =================================================================== --- SectionGroupInfo.cs (revision 68577) +++ SectionGroupInfo.cs (working copy) @@ -198,9 +198,9 @@ if (name == "section") cinfo = new SectionInfo (); - else if (name == "sectionGroup") + else if (name == "sectionGroup") { cinfo = new SectionGroupInfo (); - else + } else ThrowException ("Unrecognized element: " + reader.Name, reader); cinfo.ReadConfig (cfg, streamName, reader); @@ -210,6 +210,9 @@ if (actInfo != null) { if (actInfo.GetType () != cinfo.GetType ()) ThrowException ("A section or section group named '" + cinfo.Name + "' already exists", reader); + // Merge all the new data + actInfo.Merge (cinfo); + // Make sure that this section is saved in this configuration file: actInfo.StreamName = streamName; } @@ -340,9 +343,33 @@ if (data != null) return data; } + // It might be in the root section group return null; } + internal override void Merge (ConfigInfo newData) + { + SectionGroupInfo data = newData as SectionGroupInfo; + if (data == null) + return; + ConfigInfo actInfo; + if (data.sections != null && data.sections.Count > 0) + foreach (string key in data.sections.AllKeys) { + actInfo = sections[key]; + if (actInfo != null) + continue; + sections.Add (key, data.sections[key]); + } + + if (data.groups != null && data.sections.Count > 0) + foreach (string key in data.groups.AllKeys) { + actInfo = groups[key]; + if (actInfo != null) + continue; + groups.Add (key, data.groups[key]); + } + } + public void WriteRootData (XmlWriter writer, Configuration config, ConfigurationSaveMode mode) { WriteContent (writer, config, mode, false);
signature.asc
Description: PGP signature
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list