Link to home
Start Free TrialLog in
Avatar of lizmarc
lizmarc

asked on

Saving app configuration settings

I use the Settings tab of the Projectt Properties page (VS 2012, C#) to create application configuratioon settings.  I can read them just fine in code.  But when I try to modify them I get an error.  Because I'm using the settings tab, I can write code like this to read settings fine.

string team = Properties.Settings.Default.Team;

where Team is a setting I made.  According to MSDN, I should be able to modify then save settings in code like this.

Properties.Settings.Default.Team = "My team";
Properties.Settings.Default.save();

But when I try to set the value I get this error:  Error      5      Property or indexer 'GameCenter.Properties.Settings.Team' cannot be assigned to -- it is read only      D:\Programs\GameCenter\GameCenter\GCSettings.cs      57      13      GameCenter

I have tried using Configuration = config = ConfigurationManager.OpenExeconfiguration(. . .) and then working with the appsettings.settings stuff but I can't even read doing that because I think I'm using the prefered newer way of handle configuration.  Any thoughts on why I can't write back to the app.config file?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial