Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Application Settings and reading defaults from app.config

I need to deploy a Windows Forms application using ClickOnce deployment. (VS2008, .NET 3.5) And I need to provide a configuration file for this app that any user can modify. For this reason, I am using Application Settings instead of standard appSetttings in app.config so I can separate the the user config from app config.

see http://msdn.microsoft.com/en-us/library/ms228995(VS.80).aspx

Creating a Settings.settings file using VS generated a class with hard-coded default values like this:

[global::System.Configuration.DefaultSettingValueAttribute("blahblah")]
public string MyProperty
...

I want to read the default values from the app.config!

So I created my own class deriving from ApplicationSettingsBase but I cannot get this to read values from the app.config. Any ideas?

like image 299
Peter Goras Avatar asked Nov 15 '22 11:11

Peter Goras


1 Answers

I wrote my own configuration class to retain settings. Another thing that might be helpful to you is if you want the settings to be retained when the ClickOnce app is updated, I recommend you put it somewhere other than the ClickOnce cache. This will also make it easier for your users to find it. This article recommends LocalApplicationData (because you can write to it with Vista or Win7), but you might even want to put it under MyDocuments since you want the user to be able to edit it.

http://robindotnet.wordpress.com/2009/08/19/where-do-i-put-my-data-to-keep-it-safe-from-clickonce-updates/

RobinDotNet

like image 128
RobinDotNet Avatar answered Dec 24 '22 06:12

RobinDotNet