473,804 Members | 3,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Watching changes in the App.config file on runtime

Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay
Nov 16 '05 #1
6 5960
Check out the FileSystemWatch er class in the framework:

http://msdn.microsoft.com/library/de...sctortopic.asp
This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:ul******** *****@TK2MSFTNG P15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay

Nov 16 '05 #2
Hi,

You can use a FileSystemWatch er to monitor the file

What I do not know for sure is the consecuence of changing this file, in a
web app if you change it the application is restarted, you lose all the
sessions and you don't need to check for changes. I don't know what happen
in a web service.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:ul******** *****@TK2MSFTNG P15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay

Nov 16 '05 #3
Thanks for the response.
But the problem I am facing is little different:

I want to use the System.Configur ation.Configura tionSetting.App Settings
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configur ation.Configura tionSetting.App Settings member function it is
the original one, is there a way to force reading back the .config file ?
"PJ Olson" <pe*****@sux.co m> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
Check out the FileSystemWatch er class in the framework:

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

This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:ul******** *****@TK2MSFTNG P15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay


Nov 16 '05 #4
Thanks for the response.
But the problem I am facing is following:

I want to use the System.Configur ation.Configura tionSetting.App Settings
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configur ation.Configura tionSetting.App Settings member function it is
the original one, is there a way to force reading back the .config file ?

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:eA******** ******@TK2MSFTN GP09.phx.gbl...
Hi,

You can use a FileSystemWatch er to monitor the file

What I do not know for sure is the consecuence of changing this file, in a
web app if you change it the application is restarted, you lose all the
sessions and you don't need to check for changes. I don't know what happen
in a web service.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:ul******** *****@TK2MSFTNG P15.phx.gbl...
Hi,

I am creating a web service, which needs to take some actions based on the config file. I need a way to listen the changes as they occur in the
config
file so that the service can take appropriate action for the cahnges. Is
there any way i can implement this.

Thanks,
Ajay


Nov 16 '05 #5
>I want to use the System.Configur ation.Configura tionSetting.App Settings
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configu ration.Configur ationSetting.Ap pSettings member function it is
the original one, is there a way to force reading back the .config file ?


No - you will have to "roll your own" and read and interpret the
app.config file (a XML file) yourself.

The basic .NET framework does *NOT* assume that those files are
changed while the app is running, and thus they read the settings
ONCE, at startup, and never again after that (they're being cached).

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)i nova.ch
Nov 16 '05 #6
Store the settings in a custom application specific Settings class. Use that
class to receive updates and update the web.config at the same time as well
as providing the current settings to your web service.

Provide a property for each setting will also provide the equivalent of a
Typed Dataset type environment preventing runtime errors due to mispelled
app settings.

"Pretend" the web service has no knowledge of the
System.Configur ation.Configura tionSetting.App Settings area and uses your
custom Settings class instead.

Your app will then always have the latest values at hand!

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:Oq******** ******@TK2MSFTN GP09.phx.gbl...
Thanks for the response.
But the problem I am facing is little different:

I want to use the System.Configur ation.Configura tionSetting.App Settings
member function to retrieve settings from the my app.config file.
If some of the settings in the app.config are changed and when I read back
values from
System.Configur ation.Configura tionSetting.App Settings member function it
is
the original one, is there a way to force reading back the .config file ?
"PJ Olson" <pe*****@sux.co m> wrote in message
news:OG******** ******@TK2MSFTN GP14.phx.gbl...
Check out the FileSystemWatch er class in the framework:

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


This will provide everything you need.

"Ajay Pal Singh" <aj***@nagarro. com> wrote in message
news:ul******** *****@TK2MSFTNG P15.phx.gbl...
> Hi,
>
> I am creating a web service, which needs to take some actions based on the > config file. I need a way to listen the changes as they occur in the
> config
> file so that the service can take appropriate action for the cahnges.
> Is
> there any way i can implement this.
>
> Thanks,
> Ajay
>
>



Nov 16 '05 #7

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

Similar topics

3
7077
by: Danny | last post by:
Hello, I was wondering if anyone knew if it was possible to make changes to an application's App.config file at runtime and then be able to access those changes immediately. The following is an example of what I'm trying to achieve: I tried a test by creating a simple app Test.exe that has some basic settings made available to it in the runtime file Test.exe.config.
9
3218
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My questions are below... "David Good" wrote: > We have a network running both Win2k and Win2k3 webservers and our web sites > reside on a UNC network share that happens to be a Network Appliance NAS.
8
34673
by: Subra Mallampalli | last post by:
Hi, I am trying to use <runtime> section within the web.config file. However, the contents of the <runtime> section seem to be ignored. What am i missing here? Is <runtime> section not used by web apps? Any help is greatly appreciated. Thanks,
3
2236
by: Lisa | last post by:
Suddenly, the encoding in my exe.config file changes from UTF-8 to Windows-1252 every time I try to debug my winform app. This causes the old application configuration error when I try to debug the app. How can I finally convince my exe.config file to keep straight?
4
2765
by: keithb | last post by:
How can an application change settings in the web.config file? I need to allow users to configure SMTP email settings with functionality similar to that provided developers by the ASP.NET Web Site Administration Tool. I believe that I can get the settings using ConfigurationManager.GetSection, but how can I save changes? If I do find a way to save changes, how can I get IIS to read the file again so that the changes become immediately...
0
1867
by: Dave A | last post by:
When I register a remoting service programmatically things work great but when I register the service using a config file I get the error "Requested Service not found" when invoking a server activated object and "Type 'RemotingTest.ClientActivated, RemotableObjects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not registered for activation" when attempting to call the client activated object. Can someone point out the...
0
1592
by: Matt Adamson | last post by:
Guys, When writing unit tests for our assemblies we'd like to change configuration values at runtime for some tests i.e. to test all code paths are executed. e.g. one method would create a test with a value set to true and the next test method would set it to false. I can set the values in the config file easy enough using the following approach
1
3320
by: Harold Howe | last post by:
When .NET loads an app.config at runtime (myapp.exe.config), will it honor an entity declaration? Based on what I am seeing, the answer is no, but I think, or hope, that I am doing something wrong. I tried this: // myapp.exe.config <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE configuration >
3
2343
by: Eric | last post by:
I'm trying to manipulae my app.config file. Below is code to test that I can remove a ConfigurationSection. It looks like its working, but the app.config file is not changed when I look at it after. I think it has something to do with the file path; the .FilePath returned <C:\Projects\MyProject\src\Core.Tests\bin\Debug\MyProject.Core.Tests.dll.temp.config> isn't app.config but I've seen a couple of places that say that...
0
9576
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
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
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
5516
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...
1
4292
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
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2988
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.