Sometime there is a need to bind to a configuration file other then app.exe.config for example when creating plugins for a 3rd party host application or when deploying the app to com+ wouldn’t you prefere to use your own config file other then the appname.exe.config ? (dllhost.exe.config)
Its very easy to redirect the AppSettingsReader to a diffrent config file using :
Any call to System.ConfigurationSettings.AppSettings will now use the new binding
Note: You can only bind once in app domain instance to a configuration file meaning changing the binding should be done before using the app.config for the first time.
1. Save the the following config file as c:\ohad.config
<?xml version="1.0" encoding="utf-8" ?>
<add key="name" value="the value"/>
</configuration>2. Create a simple windows forms application and paste the following lines: