Windows Develop Bookmark and Share   
 index > Windows Forms General > User.config and app.exe.config
 

User.config and app.exe.config

Hi,


I have managed to add new settings (user scope) at runtime and these get saved to the user.config file. However, on the next run of the application, these new settings are notloaded. It doesnt seem to exist in the collection- Properties.Settings.Default.Properties. I believe this is because the app.exe.config does not have them and only user.config has these new settings.

1) How do I sync the user.config and app.exe.config so that any new added settings (at runtime) are loaded in the collection on the next application run?

2) If I am able to do 1, will the application upgrade(via clickonce)merge the user.config file with the new app.exe.config and include the new properties?


Thanks.
Software Developer - Web/Mobile Applications
Dipesh A.  Saturday, February 14, 2009 10:17 PM
Hi,

Yes I did call the save method. The real issue was I was not setting the value of the PropertyValue property. This fixed it. I have already seen that article you pointed at. But this doesnt not talk about both 1 nor 2.

Regarding 2, new properties added at runtime are not loaded because they dont exist in the app.exe.config. If you want to add some new properties at runtime (and want them to be read during next load), you need to write them to an XML file and mark this file as a data file thus serving the purpose of not being overwritten during the application upgrade (clickonce feature). Best to use a dataset to read/write the xml file. And add each new property as a row in the table within the dataset.


Dipesh

Software Developer - Web/Mobile Applications
  • Marked As Answer byDipesh A. Friday, February 20, 2009 12:03 PM
  •  
Dipesh A.  Friday, February 20, 2009 12:03 PM
Hi Dipesh A_,

Did you call the Save method of the Default property of the Setting? The save method is used to save the changes we do to the settings.

For your second questions, the application upgrade via clickonce will update the application file according to its update policy. Please refer to this article for the detail information.

If you have any further problem, please feel free to let me know.

Best regards,
Bruce Zhou

Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Tuesday, February 17, 2009 2:50 AM
Hi,

Yes I did call the save method. The real issue was I was not setting the value of the PropertyValue property. This fixed it. I have already seen that article you pointed at. But this doesnt not talk about both 1 nor 2.

Regarding 2, new properties added at runtime are not loaded because they dont exist in the app.exe.config. If you want to add some new properties at runtime (and want them to be read during next load), you need to write them to an XML file and mark this file as a data file thus serving the purpose of not being overwritten during the application upgrade (clickonce feature). Best to use a dataset to read/write the xml file. And add each new property as a row in the table within the dataset.


Dipesh

Software Developer - Web/Mobile Applications
  • Marked As Answer byDipesh A. Friday, February 20, 2009 12:03 PM
  •  
Dipesh A.  Friday, February 20, 2009 12:03 PM

You can use google to search for other answers

Custom Search

More Threads

• Move a textbox at runtime?
• how to limit number of instances of a form being opened?
• MsAccess automation problem in vb.net
• How to send an event from a UserControl to its container?
• Panel.AutoScroll not working with nested TableLayoutPanel
• How to add children to a MdiContainer form
• display the form in first view at mdiForm
• Get global ip in winforms?
• dynamic object generation in C#
• Listview columns