The other posts seem a bit confusing. So here's a clearer reply
I have a Windows Service running (made in VB.NET), and wanted to be
able to change from time to time some parameters by changing them in
the App.config. But it seems that the application doesn't use the
changed values in the App.config, but continue to use the values that
were there during start-up.
The application configuration file is named after the process, so if you
have a process called app.exe the configuration file is called
app.exe.config. VS.NET allows you to add a configuration file to a project
and it calls it app.config. When you build the project it copies this file
to the output folder and renames it according to the name of the process.
Is there a way to let the application use the new values in the
App.config? Is there kind of some 'refresh' function that I should
run? Or should I do this on an other way?
You cannot do it. The settings in the config file should be treated like
command line switches, once the process has started you cannot change them.
Actually, that is not strictly true, but it is a good rule of thumb. Here's
how it works. Each application domain in the process will read the
configuration and get its own copy, normally you will have just one
application domain in your process. When the appdomain wants to read a value
the *section* that contains the value is read (the sections are defined in
the machine.config file). The system will get the combination of the section
from machine.config and the application's file and use this XML to
initialize a configuration handler. The handler will generate some kind of
object from this (usually a collection object, but it doesn't have to be)
and the system stores it in a Hashtable in the appdomain. The next time that
a value is read from the section, the object cached in the Hashtable is
used.
This means that for an application domain, a setting is only read once from
the config file and after that the cached value is used. If you want to
change the config file during runtime you will have to use something like a
FileSystemWatcher on the config file, and when the file changes you will
have to use the XML classes to read the file and update your settings.
Richard