?
Solved

Saving app configuration settings

Posted on 2013-11-23
1
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 900 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 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