In our project we have defined a custom configuration section which works fine when being referenced in the project. Now we are trying to reference this same configuration section from a dll which is added as a reference. From the code in this dll we can access ConfigurationManager.AppSettings with no problems but getting errors when accessing configuration entry.
<section name="mailManager" type="FullNamespace, NameSpace" />
<prop2 key1="keyVal1" key2="keyVal2" key3="keyVal3" />
<prop3 key1="keyVal1" key2="keyVal2" />
var mailManagerConfigSection = ConfigurationManager.GetSection("mailManager") as EmailManagerConfigSection;
Configuration sections must be defined, loaded, and referenced from an executable, not from a DLL.
You can keep the source code for the config file in the dll project in your solution space, but wherever the compile of the dll puts the config file, the app.config for the host executable (that references the dll) must declare and specify that file in it's app.config [ApplicationName.Exe.config] Just add the appropriate
<section> element and actual section element for the config into the host executables app.config.