I need to create a configuration section, that is able to store key-value pairs in an app.config file and the key-value pairs can be added runtime regardless of their type. It is also important that the value keeps its original type. I need to extend the following interface
public interface IPreferencesBackend
{
bool TryGet<T>(stri...
I'm trying to create classes to read from my config file using ConfigurationSection and ConfigurationElementCollection but am having a hard time.
As an example of the config:
<PaymentMethodSettings>
<PaymentMethods>
<PaymentMethod name="blah blah" code="1"/>
<PaymentMethod name="blah blah" code="42"/>
<PaymentMethod name...
I would like to load a specific ConfigurationSection but the way the CLR loads the assemblies is giving me some trouble:
My CustomConfigurationSection definition is on a specific assembly which cannot be found by the overall process of assembly loading, because I'm using an external tool which basically loads my assembly, discovers some...
Hi folks,
i've got some custom config entries in my .config files. All loads/works fine. I was wondering if there's a proper way to check the data that has been provided -- adding some business logic. For example...
<logFileSettings>
<logFile fileName="foo.log" uniqueName="log1">
<alerts>
-= snip =-
</a...
I've been scouring the net for the last 3 days, and can't find any reference to this question. I've created a custom configuration class to be used with my app.config. Everything works fine. The problem comes in when a configuration property (of a configuration element) is not required, and is not defined in the app.config. It seems t...
I am working on a component/assembly that is to be distributed to other developers and included in their systems.
In order to minimize the work they have to do, all configuration is done in a seperate file (my.config).
My current problem is that a library I am using requires configuration to be added to the app.config file of the appli...
I'm trying to get a custom web.config section to get inherited by an application's web.config in a website subfolder.
The custom section works fine in the main website, but it appears the custom section isn't inherited.
Other elements in the web.config are getting inherited - it's just this custom section which isn't.
Is this by des...
I am writing a configuration system in which the app.config file is dynamically constructed from various config fragments distributed across multiple locations. The system currently works as follows:
Bootstrapper builds configuration file.
Bootstrapper initializes new AppDomain with new config file as the configuration file.
As a resul...
I have created a configuration section designer project to represent nodes of a custom section necessary to read and save from my web application. I am able to successfully create instances of the configuration elements and collections, however when I save the configuration using the referenced System.Configuration.Configuration object ...
The entry 'MyCustomElement' has already been added.
C:\Projects\Sandbox\Sandbox.Console\bin\Debug\Sandbox.Console.vshost.exe.config line 52
I'm a bit stumped on this one. This console app has had quite a few custom config sections added over the past few weeks with no issue. We've run the app for some time and just recently(within the...
Hi,
We are trying to create a "proxy" class that would serve the WCF service with its configuration properties.
Because we can't store those properties in the app.config file, i'm looking for a way to "proxy" it out and use custom configurationSection which would provide all these data upon request. In order to do so, i would need to ...
Hi,
I'm trying to build a custom configuration and with some reason, I can't get it work. I'll appreciate if anyone can see where my problem is.
Here is the code:
public class PointServices : ConfigurationSection
{
public static PointServices Get()
{
var t = ConfigurationManager.GetSection("point.Se...
hi,
I'm getting the following exeption:
"Sections must only appear once per config file. See the help topic for exceptions. "
my configuration file look like this:
<configSections>
<sectionGroup name="point.System">
<section name="singleInstanceCache" type="xyz.Point.System.Configuration.SingleInstanceCache, Point.System" ...
I have the following code
var section = new CustomConfigurationSection();
section.SectionInformation.Type = "System.Configuration.NameValueFileSectionHandler";
section.SectionInformation.SetRawXml(sectionXml);
configuration.Sections.Add(sectionName, section);
last line of which throws:
ConfigurationErrorsException An error
occur...
I have a class containing the following ConfigurationSection:
namespace DummyConsole {
class TestingComponentSettings: ConfigurationSection {
[ConfigurationProperty("waitForTimeSeconds", IsRequired=true)]
[IntegerValidator(MinValue = 1, MaxValue = 100, ExcludeRange = false)]
public int WaitForTimeSeconds
{
get...
So this a new one for me.
I'm trying to define a ConfigurationSection class in my class library that pulls from App.Config in my WinForms app. I've never done this before but from following examples this is where I've got to.
app.config in my WinForms app
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<...
Is it possible and how to instantiate a custom System.Configuration.ConfigurationSection derived class from a different source (not dependent on App.config)?
Here is what i want to get:
[TestMethod]
public void WorkWithALoadedConfiguration()
{
ProjectConfiguration projectConfiguration =
LoadProjectConfiguration(filenameOrStreamOrXE...
I have a console application that is trying to load a CustomConfigurationSection from a web.config file.
The custom configuration section has a custom configuration element that is required. This means that when I load the config section, I expect to see an exception if that config element is not present in the config. The problem is t...
I am trying to create a virtual directory and set it's permissions using IIS7 and C#. Here is a sample of my code:
using (ServerManager serverManager = new ServerManager(webSite))
{
ConfigurationSection anonymousAuthenticationSection =
config.GetSection(
@"system.webServer/security/authentication/anonymousAuthenticat...
I've got aConfiguration object that I can easily read and write settings from and call Save(ConfigurationSaveMode.Minimal, true) on and that typically works just fine.
However, I now have a config file that has a custom sectionGroup defined of type System.Configuration.NameValueSectionHandler (I didn't write that part and I can't chan...