configurationsection

ConfigurationProperty is inaccessible due to its protection level

我怕爱的太早我们不能终老 提交于 2019-11-30 18:37:38
I wanna read/write (and save) application's configuration file in program The app.config is like this: <configuration> <configSections> <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler" requirePermission="false"/> </configSections> <AdWordsApi> <add key="LogPath" value=".\Logs\"/> ... </AdWordsApi> </configuration> When I use ConfigurationManager.GetSection to read the app.config, it works: var adwords_section = (System.Collections.Hashtable) System.Configuration.ConfigurationManager.GetSection("AdWordsApi"); Console.WriteLine((string)adwords_section["LogPath"]);

custom ConfigurationSection

我是研究僧i 提交于 2019-11-30 03:45:05
I use IConfigurationSectionHandler interface to get information about my custom config section. But it's deprecated and I want to use ConfigurationSection instead. How to create custom ConfigurationSection with this view and using ConfigurationSection instead IConfigurationSectionHandler: <CustomSectionBlaBla> <Parent name="DB"> <FirstChild value="someValue"/> <SecondChild value="someValue"/> <Parent/> ... <Parent name="UI"> <FirstChild value="someValue"/> <SecondChild value="someValue"/> <Parent/> <CustomSectionBlaBla/> Here's an example of a configuration section that I created. Should point

ConfigurationProperty is inaccessible due to its protection level

喜欢而已 提交于 2019-11-29 18:20:50
问题 I wanna read/write (and save) application's configuration file in program The app.config is like this: <configuration> <configSections> <section name="AdWordsApi" type="System.Configuration.DictionarySectionHandler" requirePermission="false"/> </configSections> <AdWordsApi> <add key="LogPath" value=".\Logs\"/> ... </AdWordsApi> </configuration> When I use ConfigurationManager.GetSection to read the app.config, it works: var adwords_section = (System.Collections.Hashtable) System.Configuration

custom ConfigurationSection

帅比萌擦擦* 提交于 2019-11-29 01:19:54
问题 I use IConfigurationSectionHandler interface to get information about my custom config section. But it's deprecated and I want to use ConfigurationSection instead. How to create custom ConfigurationSection with this view and using ConfigurationSection instead IConfigurationSectionHandler: <CustomSectionBlaBla> <Parent name="DB"> <FirstChild value="someValue"/> <SecondChild value="someValue"/> <Parent/> ... <Parent name="UI"> <FirstChild value="someValue"/> <SecondChild value="someValue"/>

How do you use sections in c# 4.0 app.config?

核能气质少年 提交于 2019-11-28 03:08:16
I want to use my app config to store the settings for 2 companys, and i'd prefer if it was possible to use a section to seperate the data for one from the other rather then giving them diffrent key names. I have been checking online but i seem to get a bit overwhelmed when people use sections or find outdated easy ways to use them. could anyone pass me a beginner guide on them? Below is an example of what my app.config would look like: <configSections> <section name="FBI" type="" /> <section name="FSCS" type="" /> </configSections> <FSCS> <add key="processingDirectory" value="C:\testfiles

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

好久不见. 提交于 2019-11-27 16:06:39
问题 Here's the idea I had: I want a small executable to have an app.config file with multiple sections that are situated under the sectionGroup "applicationSettings" (not "appSettings", I don't need to write to the file). Each section would have a name corresponding to a module that should be loaded if set. Here's an example: <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral,

Correct implementation of a custom config section with nested collections?

不问归期 提交于 2019-11-27 11:02:00
In a web application, I want to be able to define some mapping using a config section like this: <configuration> <configSections> <sectionGroup name="MyCustomer"> <section name="CatalogMappings" type="MyCustom.MyConfigSection" /> </sectionGroup> </configSections> <MyCustomer> <catalogMappings> <catalog name="toto"> <mapping value="1" displayText="titi" /> <mapping value="2" displayText="tata" /> </catalog> <catalog name="toto2"> <mapping value="1" displayText="titi2" /> <mapping value="2" displayText="tata2" /> </catalog> </catalogMappings> </MyCustomer> </configuration> I'm struggling to

How do you use sections in c# 4.0 app.config?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 00:00:48
问题 I want to use my app config to store the settings for 2 companys, and i'd prefer if it was possible to use a section to seperate the data for one from the other rather then giving them diffrent key names. I have been checking online but i seem to get a bit overwhelmed when people use sections or find outdated easy ways to use them. could anyone pass me a beginner guide on them? Below is an example of what my app.config would look like: <configSections> <section name="FBI" type="" /> <section

Can't load a manifest resource with GetManifestResourceStream()

一曲冷凌霜 提交于 2019-11-26 16:11:41
问题 I've created a custom configuration section using XSD. In order to parse the config file that follows this new schema, I load the resource (my .xsd file) with this: public partial class MonitoringConfiguration { public const string ConfigXsd = "MonitoringAPI.Configuration.MonitoringConfiguration.xsd"; public const string ConfigSchema = "urn:MonitoringConfiguration-1.0"; private static XmlSchemaSet xmlSchemaSet; static MonitoringConfiguration() { xmlSchemaSet = new XmlSchemaSet(); Stream

How to get the values of a ConfigurationSection of type NameValueSectionHandler

本小妞迷上赌 提交于 2019-11-26 15:51:34
问题 I'm working with C#, Framework 3.5 (VS 2008). I'm using the ConfigurationManager to load a config (not the default app.config file) into a Configuration object. Using the Configuration class, I was able to get a ConfigurationSection , but I could not find a way to get the values of that section. In the config, the ConfigurationSection is of type System.Configuration.NameValueSectionHandler . For what it worth, when I used the method GetSection of the ConfigurationManager (works only when it