2 using System.Collections.Generic;
3 using System.Collections.Specialized;
5 using System.Configuration;
8 // test to see how we react when the default value for an attribute is
10 public class CustomSection : ConfigurationSection
12 public CustomSection()
16 [LongValidator(MinValue = 1, MaxValue = 1000000,
17 ExcludeRange = false)]
18 [ConfigurationProperty ("longSetting", DefaultValue="wrong type")]
19 public long LongSetting
21 get { return (long)this["longSetting"]; }
22 set { this["longSetting"] = value; }
28 static void Main(string[] args)
32 Console.WriteLine ("1");
33 Configuration config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None);
34 Console.WriteLine ("2");
35 CustomSection sect = (CustomSection)config.GetSection("customSection");
37 Console.WriteLine ("longSetting = {0}", sect.LongSetting);
41 Console.WriteLine ("Exception raised: {0}", e.GetType());