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.
HOW TO: Create a Custom ASP.NET Configuration Section Handler in Visual C#
NET
http://support.microsoft.com/?id=309045
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
"Wells Caughey" <wellsc...@hotmail.com> wrote in message
news:O1Df4dAC...@TK2MSFTNGP12.phx.gbl...
Sorry for the late reply due to my OOF. Nice to hear that the problem was
solved.