How to get all sections by name in the sectionGroup applicationSettings in .Net 2.0

Take a look at the ConfigurationManager.OpenExeConfiguration function to load in your configuration file. Then on the System.Configuration.Configuration class that you’ll get back from ConfigurationManager.OpenExeConfiguration you’ll want to look at the SectionGroups property. That’ll return a ConfigurationSectionGroupCollection in which you’ll find the applicationSettings section. In the ConfigurationSectionGroupCollection there will be a Sections property which contains the … Read more

How to get the values of a ConfigurationSection of type NameValueSectionHandler

Suffered from exact issue. Problem was because of NameValueSectionHandler in .config file. You should use AppSettingsSection instead: <configuration> <configSections> <section name=”DEV” type=”System.Configuration.AppSettingsSection” /> <section name=”TEST” type=”System.Configuration.AppSettingsSection” /> </configSections> <TEST> <add key=”key” value=”value1″ /> </TEST> <DEV> <add key=”key” value=”value2″ /> </DEV> </configuration> then in C# code: AppSettingsSection section = (AppSettingsSection)ConfigurationManager.GetSection(“TEST”); btw NameValueSectionHandler is not supported any … Read more

Correct implementation of a custom config section with nested collections?

I finally found this guy’s example. It was coded and worked right out of the box. http://manyrootsofallevilrants.blogspot.com/2011/07/nested-custom-configuration-collections.html I am going to paste the code here……only because I cannot stand it when someone says “Your answer is here”, and the link is dead. Please try his website first, and leave a “thank you” if it works. … Read more

Can’t load a manifest resource with GetManifestResourceStream()

The name of the resource is always: <Base namespace>.<RelativePathInProject>.<FileName> So if your resource is located in “Resources/Xsd/”, and your default project namespace is “MonitoringAPI.Configuration”, the resource name is: “MonitoringAPI.Configuration.Resources.Xsd.MonitoringConfiguration.xsd” Also make sure the build action for your resource is set to “Embedded Resource”