[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Saving app configuration settings

Posted on 2013-11-23
1
Medium Priority
?
226 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

834 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