C# ConfigurationManager Write Existing Custom Section

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?
MonMuscAsked:
Who is Participating?
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
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
 
Meir RivkinFull stack Software EngineerCommented:
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
 
MonMuscAuthor Commented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Meir RivkinFull stack Software EngineerCommented:
post the config and wrapper class for the custom section and i'll take a look
0
 
MonMuscAuthor Commented:
Attached is the cs and config file.
Config.cs
App.config
0
 
MonMuscAuthor Commented:
Didn't think about that, it's working though so wondering if white space really bothers it much...
0
 
Meir RivkinFull stack Software EngineerCommented:
License_Reporter is the name of the project/dll so it does matters.
0
 
Meir RivkinFull stack Software EngineerCommented:
any specific reason for grading this as B?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.