Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# ConfigurationManager Write Existing Custom Section

Posted on 2012-04-09
8
Medium Priority
?
400 Views
Last Modified: 2012-12-07
So I have an application that I need to have a portable configuration file for.  I have started using the ConfigurationManager object for this, and have gotten it to read an existing Custom Section, and even create a default one if there is no Custom Section meeting my name, but I can't seem to figure out how to be able to write changed values to an existing Custom Section using ConfigurationManager.  I would like to allow the user to update values as needed without editing the .config XML directly, and so far I only see that I can do this using the AppSettings section.  Anyone have an idea of how to do this using ConfigurationManager?
0
Comment
Question by:MonMusc
[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
  • 5
  • 3
8 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 37823934
you probably using something like:

 SectionType st = (SectionType)onfigurationManager.GetSection(“<section>”);

where  SectionType is your custom section wrapper class.
if you create the properties with both get and set you should be able to update your custom sections.
0
 

Author Comment

by:MonMusc
ID: 37829176
So looking at that, I would assume the thinking is that using the GetSection will create a object based on the App.Config CustomSection, and if I do a set to the property it will store it?  I'm curious because I specifically have to do an AddSection to do the initial write, but alas I will give it a shot and see if this leads me down the right path.
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 37831226
post the config and wrapper class for the custom section and i'll take a look
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

by:MonMusc
ID: 37840939
Attached is the cs and config file.
Config.cs
App.config
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 1500 total points
ID: 37847790
in your app config you have a whitespace instead of underscore in the config section type attribute.

current:
type="License_Reporter.ConfigSection, License Reporter, ...

should be:
type="License_Reporter.ConfigSection, License_Reporter, ...
0
 

Author Comment

by:MonMusc
ID: 37851212
Didn't think about that, it's working though so wondering if white space really bothers it much...
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 37851311
License_Reporter is the name of the project/dll so it does matters.
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 38670856
any specific reason for grading this as B?
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

604 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