I’m using enterprise library for logging. So, to hold my configurations, I’m using the client’s app.config. The requirement changed to “split EL configuration and UI configuration”. I did it using enterpriseLibrary.ConfigurationSource. Split the configurations to app.config(For UI) and EL.config(For EL).
Now I want to hide the reference to this EL.config from app.cpnfig, so that the mere existence of this EL>config is hidden from the User.
App.config Code:
<enterpriseLibrary.ConfigurationSource selectedSource="EntLib Configuration Source">
<sources>
<add name="EntLib Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
filePath="C:\My.CommonServices.Logging\My.CommonServices.Logging\EL.config" />
</sources>
You can use
FileConfigurationSourceto programmatically load an external configuration file.During application load or initialization you can load your external configuration file:
Once that is done you can access your favorite features:
The only “trick” is ensuring that the configuration file is always present where you expect (either absolute or relative).