Change default app.config at runtime

The hack in the linked question works if it is used before the configuration system is used the first time. After that, it doesn’t work any more. The reason: There exists a class ClientConfigPaths that caches the paths. So, even after changing the path with SetData, it is not re-read, because there already exist cached … Read more

Equivalent to ‘app.config’ for a library (DLL)

You can have separate configuration file, but you’ll have to read it “manually”, the ConfigurationManager.AppSettings[“key”] will read only the config of the running assembly. Assuming you’re using Visual Studio as your IDE, you can right click the desired project → Add → New item → Application Configuration File This will add App.config to the project … Read more

Pros and cons of AppSettings vs applicationSettings (.NET app.config / Web.config)

The basic <appSettings> is easier to deal with – just slap in a <add key=”….” value=”…” /> entry and you’re done. The downside is: there’s no type-checking, e.g. you cannot safely assume your number that you wanted to configure there really is a number – someone could put a string into that setting….. you just … Read more

How to implement a ConfigurationSection with a ConfigurationElementCollection

The previous answer is correct but I’ll give you all the code as well. Your app.config should look like this: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <configSections> <section name=”ServicesSection” type=”RT.Core.Config.ServiceConfigurationSection, RT.Core”/> </configSections> <ServicesSection> <Services> <add Port=”6996″ ReportType=”File” /> <add Port=”7001″ ReportType=”Other” /> </Services> </ServicesSection> </configuration> Your ServiceConfig and ServiceCollection classes remain unchanged. You need a new … Read more

C# DLL config file

It is not trivial to create a .NET configuration file for a .DLL, and for good reason. The .NET configuration mechanism has a lot of features built into it to facilitate easy upgrading/updating of the app, and to protect installed apps from trampling each others configuration files. There is a big difference between how a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)