<appSettings> in file myapplication.exe.config getting overwritten everytime I start my app.

Posted on 2006-05-19
Last Modified: 2007-12-19

I use the appsettings section of the config file to store local application variables.  They get written fine during my app (I can check the contents while the app is running and all is fine) but as soon as I stop my app. and then invoke it again the .config file is reset all my settings are gone!  All that's left is the basic structure with my sql connection line.

I am currently running this in debug mode and what seems to be happening is that when I update my myapplication.exe.config file this is is done in the debug folder, however, each time my app runs a file called app.config, in my solution folder, is copied into the debug folder overwritting my newly updated .config file!

Why / which file should I be updating??????

Any thoughts.

Many thanks.

Question by:JAMES
    LVL 8

    Assisted Solution

    As I know app.config file should store configuration parameters for program executing.
    I suggest to save your local variables in other file (Xml, for example) or in the registry.


    Author Comment

    As far as I am aware Microsoft are trying to push users towards storing local app. settings in this file so it's a bit annoying they make it so hard!

    I want to avoid the registry and are already looking at using another config file but I wondered if there was a reason why my problem exists and, therefore, a solution!

    Thanks anyway.
    LVL 19

    Accepted Solution

    Because each time you save settings to your config file, the new entries are written to the debug\bin\Appconfg.config
    this file is overwritten each time when you run your application from VD.Net IDE.
    When you will run your app directly from bin folder, it wont happen . Also this wont happen if you are going to deploy your app.
    The only solution to this is to have a separate xml file

    Author Comment

    Ok - neither of you really solved my problem just reiterated what I had already discovered and mentioned but at least I am now sure it's not something I am doing wrong.

    I hope you both don't mind if I split the points.

    Thanks for your input.

    Author Comment


    The solution i did use was that in my app.config class I wrote I use a condition to check if I am in debug mode - if I am I write to the app.config of the solution folder in addition to my myapplication.exe.config file.

    That way when the program starts within it copies the file as usual but this time it now contains the values i previously stored!


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now