Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BUG? Custom ConfigurationSectionHandler does not work in 1.1

0 views
Skip to first unread message

Wells Caughey

unread,
Apr 18, 2003, 11:53:02 AM4/18/03
to
I didn't know where to report it, but it does not appear that you can define
a custom ConfigurationSectionHandler in version 1.1. I tried a number of
different ways to get it to work and finally gave up reverting to version
1.0 bits.

Wells


Ryan Lu [MSFT]

unread,
Apr 21, 2003, 5:32:33 AM4/21/03
to
Hi Wells,

What was the problem you met? I've tried KB 309045 with VS.NET 2003 just
now and did not get problems. Would you please post the detailed exception?
If you have repro steps/code, please post here also and I will help to
figure it out.

Best regards,

Ryan Lu
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.

Ryan Lu [MSFT]

unread,
Apr 21, 2003, 5:33:32 AM4/21/03
to
Sorry that I forgot the article link. Please follow the KB article to have
a test again.

HOW TO: Create a Custom ASP.NET Configuration Section Handler in Visual C#
NET
http://support.microsoft.com/?id=309045

Wells Caughey

unread,
Apr 21, 2003, 9:11:06 AM4/21/03
to
Hi Ryan, thanks for your reply.

This is the relevant portion of my app.config file:

<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
<configSections>
<sectionGroup name="MapGenerator">
<section name="mapSettings" type="SpatialLibrary.LayerSection,
SpatialLibrary, Version=1.0.1180.24045, Culture=neutral,
PublicKeyToken=null" />
</sectionGroup>
... more stuff omitted
</configSections>
<MapGenerator>
<mapSettings>
<layer format="{2}_{0}_dn" color="0x00ff00" width="3" style="0" />
<layer format="{0}_all_00" color="0xf00000" width="2" style="0" />
<layer format="{0}_all_01" color="0x808080" width="2" style="0" />
<layer format="{0}_all_03" color="0x808080" width="2" style="0" />
<layer format="{0}_all_04" color="0x808080" width="1" style="0" />
<layer format="{0}_all_05" color="0x808080" width="1" style="0" />
<layer format="{0}_all_rr" color="0x804040" width="1" style="2" />
<layer format="{0}_all_06" color="0xaeaeae" width="1" style="0" />
<layer format="{0}_all_wl" color="0x0080ff" width="1" style="0" />
<layer format="{0}_all_wa" color="0x0080ff" width="1" style="0" />
<layer format="{0}_all_a8" color="0xf0ecca" width="1" style="0" />
</mapSettings>
</MapGenerator>
... other stuff omitted
</configuration>

This is the LayerDefinition and LayerSection classes:

public class LayerDefinition
{
public LayerDefinition(XmlNode node)
{
String color = node.Attributes["color"].Value.Replace("0x",
String.Empty);

Format = node.Attributes["format"].Value;
Color = Color.FromArgb(Int32.Parse(color,
System.Globalization.NumberStyles.HexNumber));
Style = Int16.Parse(node.Attributes["style"].Value);
Width = Int16.Parse(node.Attributes["width"].Value);
}

public Color Color;
public Int16 Style;
public Int16 Width;

public String Format;
}

public class LayerSection : IConfigurationSectionHandler
{
public object Create(object parent, object configContext, XmlNode section)
{
ArrayList arrayList = new ArrayList();

foreach(XmlElement layer in section.ChildNodes)
arrayList.Add(new LayerDefinition(layer));

return arrayList;
}
}

When I use all version 1.0 libraries everything works as expected. When I
upgrade the libraries to version 1.1 and execute the following code I always
get one exception or another.

private void InitializeObjects()
{
Application.Idle += new EventHandler(OnIdle);
ImageLayers = (ArrayList) ConfigurationSettings.GetConfig("mapSettings");
}

Thanks again,
Wells

"Ryan Lu [MSFT]" <ry...@online.microsoft.com> wrote in message
news:QN1VYk#BDHA...@cpmsftngxa06.phx.gbl...

Wells Caughey

unread,
Apr 22, 2003, 12:27:42 PM4/22/03
to
I think I figured out what the problem is. I was using the enumerator to
interate over the ChildNodes collection and in version 1.0 this enumerator
never returned anything but XmlElements; however in version 1.1 ChildNodes
now returns both XmlElements and XmlWhitespaceNodes (or whatever it is
called).

Wells

"Wells Caughey" <wellsc...@hotmail.com> wrote in message
news:O1Df4dAC...@TK2MSFTNGP12.phx.gbl...

Ryan Lu [MSFT]

unread,
Apr 25, 2003, 1:49:25 AM4/25/03
to
Hi Wells,

Sorry for the late reply due to my OOF. Nice to hear that the problem was
solved.

0 new messages