Configuration file reloaded on change

Topics: Enterprise Library Core, General discussion
Nov 22, 2007 at 3:40 PM
Hi,

I'm looking for a sample or an article showing how to reload configuration file when the file changed.

Here is what I mean: let's say at the beginning my app.config looks like this:

{"<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Units" value="Units" />
</appSettings>
</configuration>"}

If I change the file to:

{"<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Units" value="Units" />
<add key="Wash" value="Wash"/>
</appSettings>
</configuration>"}

I want the change to be loaded in the program.

Best Regards,

Sam
Nov 22, 2007 at 8:21 PM
You can use http://msdn2.microsoft.com/En-US/library/system.configuration.configurationmanager.refreshsection.aspx. Now, detecting when the configuration changes is a different game.

EntLib's config wrappers will detect such changes and automatically refresh the sections.

Fernando
Nov 23, 2007 at 7:41 AM
Hi Fernando,

Thx for the link, I dig into EntLib src code, and saw that there is EntLib3Src\App Blocks\Src\Common\Configuration\ConfigurationFileChangedEventArgs.cs class.
I thought this woud be use to detect changes.

Best regards,
Sam