Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you restart an app/reread app.config file when modified (.NET)?

We all know that modifying a .NET web application's web.config file restarts the app and makes it read the updated configuration. How do you do that with a console or WinForms app? Thanks :)

like image 574
cruizer Avatar asked Jan 22 '09 10:01

cruizer


People also ask

How do I reload a config file?

To reload Config, select the loaded configurations you want to reload and click Reload. You can only reload a configuration that has the status of Loaded. To refresh Configs, click Refresh. Information for all of the configs in the table is redisplayed.

When the app is running what will happen if I go and make changes to the web config?

When you edit the web. config, It will restart the AppDomain (NOT AppPool) of that web application and clears the all occupied resources and memory.

Which of the following fields is modified to make the configuration change settings available to all Windows and Web applications?

One is "Web. config" which is used for configuring the settings for a Web application and the other is "App. config" used for Windows application settings. Any changes made to the Web.


1 Answers

Probably need a FileSystemWatcher to monitor the file, and handle the relevant event. The System.Configuration.ConfigManager class might have the relevant methods to reload (method call or some such). I don't have VS in front of me, but I'd say there's definately some hooks there for sure.

like image 119
DarkwingDuck Avatar answered Oct 04 '22 00:10

DarkwingDuck