I added the correct assembly name as you described, and I do still receive messages. I noticed I only get the messages when I open the app.config file; the messages go away when I close the file.
57 Messages: Culd not find schema information for the element 'myCustomSection'.
See the DeptConfigurations.cs class and XML from the app.config file below.
001.using System;
002.using System.Configuration;
003.
004.namespace MyApp.Configuration
005.{
006. public class DeptConfigurations : ConfigurationSection
007. {
008. //private static DeptConfigurations settings = ConfigurationManager.GetSection("myCustomSection") as DeptConfigurations;
009.
010. //public static DeptConfigurations Settings
011. //{
012. // get
013. // {
014. // return settings;
015. // }
016. //}
017.
018. // Create a "departments" element collection
019. // containing "department" items/elements.
020. [ConfigurationProperty("departments")]
021. [ConfigurationCollection(typeof(DepartmentElementCollection), AddItemName = "department")]
022. public DepartmentElementCollection Departments
023. {
024. get
025. {
026. return (this["departments"] ?? new DepartmentElementCollection())
027. as DepartmentElementCollection;
028. }
029. }
030. }
031.
032.
033. public class DepartmentElementCollection : ConfigurationElementCollection
034. {
035. public DepartmentElement this[int index]
036. {
037. get { return base.BaseGet(index) as DepartmentElement; }
038. set
039. {
040. if (base.BaseGet(index) != null)
041. base.BaseRemoveAt(index);
042.
043. this.BaseAdd(index, value);
044. }
045. }
046.
047. // Create a "department" element
048. protected override ConfigurationElement CreateNewElement()
049. {
050. return new DepartmentElement();
051. }
052.
053. protected override object GetElementKey(ConfigurationElement element)
054. {
055. return (element as DepartmentElement).Name;
056. }
057. }
058.
059.
060. // Define the "department" element
061. // with "name" and "abbreviation" attributes.
062. public class DepartmentElement : ConfigurationElement
063. {
064. [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
065. public string Name
066. {
067. get { return this["name"] as string; }
068. set { this["name"] = value; }
069. }
070.
071. [ConfigurationProperty("abbreviation", IsRequired = true)]
072. public string Type
073. {
074. get { return this["abbreviation"] as string; }
075. set { this["abbreviation"] = value; }
076. }
077.
078. // Create a "dbLocations" element collection
079. // containing "dbLocation" items/elements.
080. [ConfigurationProperty("dbLocations")]
081. [ConfigurationCollection(typeof(dbLocationElementCollection), AddItemName = "dbLocation")]
082. public dbLocationElementCollection DbLocations
083. {
084. get
085. {
086. return (this["dbLocations"] ?? new dbLocationElementCollection())
087. as dbLocationElementCollection;
088. }
089. }
090. }
091.
092.
093. public class dbLocationElementCollection : ConfigurationElementCollection
094. {
095. public dbLocationElement this[int index]
096. {
097. get { return base.BaseGet(index) as dbLocationElement; }
098. set
099. {
100. if (base.BaseGet(index) != null)
101. base.BaseRemoveAt(index);
102.
103. this.BaseAdd(index, value);
104. }
105. }
106.
107. protected override ConfigurationElement CreateNewElement()
108. {
109. return new dbLocationElement();
110. }
111.
112. protected override object GetElementKey(ConfigurationElement element)
113. {
114. return (element as dbLocationElement).Name;
115. }
116. }
117.
118.
119. // Define the "dbLocation" element
120. // with "name" and "value" attributes.
121. public class dbLocationElement : ConfigurationElement
122. {
123. [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
124. public string Name
125. {
126. get { return this["name"] as string; }
127. set { this["name"] = value; }
128. }
129.
130. [ConfigurationProperty("value", IsRequired = true)]
131. public string Value
132. {
133. get { return this["value"] as string; }
134. set { this["value"] = value; }
135. }
136. }
137.}
01.<?xml version="1.0" encoding="utf-8"?>
02.<configuration>
03. <configSections>
04. <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
05. <section name="Launcher.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
06. </sectionGroup>
07. <section name="myCustomSection" type="MyApp.Configuration.DeptConfigurations, AssemblyName" />
08. </configSections>
09.
10. <myCustomSection>
11. <departments>
12. <department name="Department 1" abbreviation="D1">
13. <dbLocations>
14. <clear />
15. <dbLocation name="production" value="\\D1\fileshare\" />
16. <dbLocation name="test" value="\\D1\TestFileshare\" />
17. </dbLocations>
18. </department>
19. <department name="Department 2" abbreviation="D2">
20. <dbLocations>
21. <clear />
22. <dbLocation name="production" value="\\D2\fileshare\" />
23. <dbLocation name="test" value="\\D2\TestFileshare\" />
24. </dbLocations>
25. </department>
26. <department name="Department 3" abbreviation="D3">
27. <dbLocations>
28. <clear />
29. <dbLocation name="production" value="\\D3\fileshare\" />
30. <dbLocation name="test" value="\\D3\TestFileshare\" />
31. </dbLocations>
32. </department>
33. </departments>
34. </myCustomSection>
35.
36. <userSettings>
37. <Launcher.Properties.Settings>
38. <setting name="Environment" serializeAs="String">
39. <value>Production</value>
40. </setting>
41. <setting name="ProductionDbLocation" serializeAs="String">
42. <value />
43. </setting>
44. <setting name="TestDbLocation" serializeAs="String">
45. <value />
46. </setting>
47. <setting name="Department" serializeAs="String">
48. <value />
49. </setting>
50. <setting name="DeptAbbreviation" serializeAs="String">
51. <value />
52. </setting>
53. </Launcher.Properties.Settings>
54. </userSettings>
55.</configuration>