Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai
I am use config file for capture some values and the used for further process,i am use custom service and website,service is used for communicate with MS Access database and open API(Printer Machine) and website used for communicate with end user and MS Database (i.e)user enter details into database.I am using website to connect open API using ip address and password,that time i need to change some values in config file .so only API read details form database.

First i change the config values before go to connect API and then connect ,Once connect API with database i will restart service,once restart service the capture values in config file is reset to old value.

why it reset to old values if service is running.I will try like this,before going to change config values ,i will stop service and change values then start service,that time capture the changing values.

why if service is stop and change values then start service then values is changed what i am need.
but if service is running time ,if i change values and restart service ,the changed values not hold in config file,i mean before going to change value what in config file ,the same value is appear.(this is running service).

Below is scenario
If service is Running time.

XML
<add key="SendSettingPort" value="50001" /> 

i will change  500001 to 500002 and restart service.then what i get

 <add key="SendSettingPort" value="50001" /> 



If service stopped time


HTML
 <add key="SendSettingPort" value="50001" />

i will stop service  change  500001 to 500002 and start service.then what i get

<add key="SendSettingPort" value="50002" />
this is my need.


Note:i will give all permission for config file bcz used by website in server.like read,write...
i will chnage service config values via website.not web config file.

Pls reply asap

Regards
AravindB
Posted
Updated 1-Jan-14 16:58pm
v3

1 solution

 
Share this answer
 
Comments
Aravindba 1-Jan-14 23:18pm    
Thank u for ur reply,i can change the values in config file,but once service is restart,it goes to old value,i.e before change what default value i have in config value ,that value appear.
By default i have value in service config file,if it running time ,i will change and restart service,once restart it again appear default values only,not appear recently changing value.
Aravindba 1-Jan-14 23:18pm    
Thank u for ur reply,in service config file default it have values,when running service i will change config values via web application then i restart service,once restart service it again appear default value only,not appear recently changed value.
And this in service config file,not web config file
If you look at the Points of Interest Section of the first article, you can see that...

It says...

"Once you run this application to change the appSettings value, it will not affect an application until you Exit the application and run it again."

So, I could suggest you to write somewhere else may be in a Text File or something.
Aravindba 5-Jan-14 22:36pm    
sorry for late reply,my problem is ,if i stop service and change config files values,it change,but in running service that time if i change values are not change.why ?
Actually if you change config file contents at the runtime, it won't reflect until you restart the application.
The config values are used in application, as you are going to change them dynamically, so it will be an unstable state. That's why it reflects only after the restart.

So, I suggested you to write on a text file or XML file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900