473,770 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

App.config doesn't 'refresh' once runned?

Hi,

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.

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?

Thanks,

Pieter
Jul 21 '05
16 4209
Check out his article:

http://msdn.microsoft.com/library/de...et04222003.asp

About 3/4 of the way down, there's a section called Detecting Config File
Changes.

"DraguVaso" <pi**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

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.
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?

Thanks,

Pieter

Jul 21 '05 #11
Hi scorpion,

I don't need it right now, but it will be really helpfull for future
projects, so it would be nice if you could post it here.

Thanks a lot in advance!

Pieter

"scorpion53 061" <ad***@nospamhe rekjmsolutions. com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I have a solution which modifies app.config during runtime if that is
what you are getting at.

Post if you are interested.

"DraguVaso" <pi**********@h otmail.com> wrote in message
news:#H******** ******@TK2MSFTN GP15.phx.gbl:
Hi,

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.

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?

Thanks,

Pieter

Jul 21 '05 #12
Great!
Exactly what I was looking for!

Thanks!

"Dave Hall" <dh***@nospam.d eboy.com> wrote in message
news:eI******** ******@TK2MSFTN GP12.phx.gbl...
Check out his article:

http://msdn.microsoft.com/library/de...et04222003.asp
About 3/4 of the way down, there's a section called Detecting Config File
Changes.

"DraguVaso" <pi**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

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.

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?

Thanks,

Pieter


Jul 21 '05 #13
have a look at
http://www.west-wind.com/presentatio...ationclass.asp

--

HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

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.
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?

Thanks,

Pieter

Jul 21 '05 #14
Excellent link Dave.
Thanks much

Steve

"Dave Hall" <dh***@nospam.d eboy.com> wrote in message
news:eI******** ******@TK2MSFTN GP12.phx.gbl...
Check out his article:

http://msdn.microsoft.com/library/de...et04222003.asp
About 3/4 of the way down, there's a section called Detecting Config File
Changes.

"DraguVaso" <pi**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

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.

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?

Thanks,

Pieter


Jul 21 '05 #15
The other posts seem a bit confusing. So here's a clearer reply

DraguVaso wrote:
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
FileSystemWatch er 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
--
..NET training, development, consulting and mentoring
www.richardgrimes.com
my email ev******@zicf.b et is encrypted with ROT13 (www.rot13.org)
Jul 21 '05 #16
http://www.kjmsolutions.com/download...onfigstuff.ZIP

modifies app.config in real time.

But Richard is right. Use XML or something else. App.config was not
intended for this use.

"Richard Grimes [MVP]" <read my sig> wrote in message
news:#B******** ******@TK2MSFTN GP14.phx.gbl:
The other posts seem a bit confusing. So here's a clearer reply

DraguVaso wrote:
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
FileSystemWatch er 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


Jul 21 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
7611
by: DraguVaso | last post by:
Hi, 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. 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...
0
9432
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.