Solved

Saving app configuration settings

Posted on 2013-11-23
1
210 Views
Last Modified: 2013-11-23
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?
0
Comment
Question by:lizmarc
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 300 total points
ID: 39672162
There are 2 types of settings: Application and User.

Application settings are designed to be fixed or changed by an administrator and are thus readonly through the class that is created by the compiler and used in the application to work with the settings.

To have a read-write setting, you have to set it as a User settings, which can be done through the settings tab.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now