How to restart app.config file of application / overwrite on change (.NET)?

We all know that the change is the .NET web application. The web.config file restarts the application and forces it to read the updated configuration. How do you do this with a console or WinForms application? Thanks:)

+5
source share
7 answers

You may need a FileSystemWatcher to monitor the file and handle the corresponding event. The System.Configuration.ConfigManager class may have appropriate methods for reloading (a method call or some of them). I do not have VS in front of me, but I would say that there are probably some hooks there.

+5
source

FileSystemWatcher , .

ConfigurationManager.RefreshSection, .

+4

. FileSystemWatcher, DarkwingDuck, .

+2

FileSystemWatcher .
:

MyGeneratedSettingsFile.Default.Reload();
+2

log4net *.config. , , FileSystemWatcher, *.config.

; FileSystemWatcher - .

+1

, .

, SQL Server , , SQL Server, .

, , Oracle? , , - .

, , . , , .

IoC, - .

, , , - , , .

, , , , , .

+1

.NET Framework 2 , . , , Save(),

My.Settings.UpdateInterval = 10
My.Settings.Save()

If the parameter is the application area, then FileSystemWatcher may be a way

0
source

All Articles