kaisersoze Posted April 28, 2006 Posted April 28, 2006 In my Application I make changes to some parameters in App.Config file. In the next method I try to read the parameters to show the changed values to the user. If I manually open the config file I see the changes but, the application is not able to see the changed variables. It is always showing the previous values. But, If I close and restart the application, then new values are seen. What am I missing, an how to show the new values. Quote Note: I think as a programmer not as a human, so use my answer at your will
*Experts* Nerseus Posted April 28, 2006 *Experts* Posted April 28, 2006 The App.Config file is a "helper" by Visual Studio - I don't know the real name, but that's what I call it. Behind the scenes, when you build your project it copies the current app.config from the "root" folder of your project to the \bin\Debug folder (or whatever release/folder you use). It also renames it to the proper name - the name matches the assembly plus a config extension. So for an EXE project named "Test.exe" you'll have "Test.exe.config". If you want to make changes while the app is running, you'll have to modify this file - open it manually in notepad (or even Visual Studio). Every time you rebuild the file will be replaced by Visual Studio with the values in the app.config file so don't forget to put your changes back in the app.config file. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Arch4ngel Posted May 4, 2006 Posted May 4, 2006 To add on what Nerseus said, changes made to the Test.exe.config require the application to restart to be effective through the normal way. However, nothing stops you from manually reading the file. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
kaisersoze Posted May 8, 2006 Author Posted May 8, 2006 Yes, I mean test.exe.config file and even thou i am reading manually from the config file the values are still the old. but once I restart the application the values are changing. by any way using reflections of anything can i change the values in the same instance. Quote Note: I think as a programmer not as a human, so use my answer at your will
VBAHole22 Posted June 14, 2006 Posted June 14, 2006 How are you writing to this file? I am trying the following without success: Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["MySetting"].Value = "newVal"; config.Save(ConfigurationSaveMode.Modified,true); ConfigurationManager.RefreshSection("appSettings"); I don't see the change in either the file or the code. Are ya'll saying that there is no way to make changes to appSettings and have them persist? I had all of my settings in an external xml file and i was reading and writing them that way but I thought this is the way we were supposed to do it for 2.0? Quote Wanna-Be C# Superstar
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.