Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:08:01+00:00 2026-05-14T15:08:01+00:00

My application have a configuration xml-file. That file contains more than 50 program settings.

  • 0

My application have a configuration xml-file. That file contains more than 50 program settings. At the present time I read and save each program setting separately. I guess It is not effiсiently for such tasks.

I need something that can auto-generate a code for load and save my program settings using predefined xml-schema.

I found a dataset in Add New Item dialog. Unfortunately, i cannot add new code to dataset1 such as events in set-accessors of properties because of this

//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.

Maybe, there is a tool that allows a user to generate a wrapper for accesing a xml-file ? Such as DataSet1, but with availability to add events.

Edit: I didn’t mark a useful answer because i read an articles (link) which you give me. I will mark useful answer later.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:08:02+00:00Added an answer on May 14, 2026 at 3:08 pm

    If you are not willing to use app.config/web.config or the properties file (which Oded and Bruno recommend and I recommend as well), I highly recommend this utility:

    Web Services Contract First (WSCF) Blue for VS2008 and VS2010

    If you’re on VS2005, you’ll want this version of the tool: http://www.thinktecture.com/resourcearchive/tools-and-software/wscf (don’t use the VS2008 version on this site. I could never get it to work right.)

    Once you have the plugin installed into Visual Studio, you’ll need an XSD schema of your XML file. (Google for an online XSD Generator.) Following the instructions found on the WSCF website, you can generate a wrapper class that will deserialize and reserialize your XML and give you an abstracted view of your XML.

    I figure it is impossible (or at least very hard) to add new node/element TYPES, but adding new instances of existing node/element types, accessing to your data, editing the data, reordering nodes, and then saving back out are all easy.

    Deserialization code looks like this:

    private MyGeneratedXMLconfigClass config;
    using (StreamReader sr = new StreamReader(filename))
    {
       XmlSerializer cXml = new XmlSerializer(typeof(MyGeneratedXMLconfigClass));
       config = (MyGeneratedXMLconfigClass)cXml.Deserialize(sr);
    }
    

    Now your XML has been de-serialized into the “config” instance of your custom class. Then you can access the whole class as a series of nested values and Lists.

    For example:

    string errorFile = config.errorsFile;
    List<string> actions = config.actionList;
    var specialActions = from action in config.actionList
                          where action.contains("special")
                          select action;
    

    Etc., etc. Then once you’re done manipulating your data, you can re-serialize with this code:

    using (StreamWriter wr = new StreamWriter(filename, false))
    {
       XmlSerializer cXml = new XmlSerializer(typeof(MyGeneratedXMLconfigClass));
       cXml.Serialize(wr, config);
    }
    

    One of the very nice things about this tool is that it auto-generates all classes as “partial” classes, so that you can feel free to extend each class on your own without fear of your code getting stomped on in case you ever need to re-generate because the XSD/XML was changed.

    I imagine this might sound like a lot, but the learning curve is actually pretty easy and once you get it installed and working, you’ll realize how stupidly easy it is. It’s worth it. I swear. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.