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 6082569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:18:15+00:00 2026-05-23T11:18:15+00:00

I have a config file that is used in several projects, general.config , looks

  • 0

I have a config file that is used in several projects, general.config, looks like:

<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
   <add key="mykey1" value="myvalue1"/>    
   <add key="mykey2" value="myvalue2"/>
</appSettings>

In one of the projects, I need to override one of the two settings. So the app.config of this project looks like:

<?xml version="1.0"?>
<configuration>
  <appSettings file="general.config">
    <remove key="mykey1"/>
    <add key="mykey1" value="anothervalue"/>
    <add key="mykey3" value="myvalue3"/>
  </appSettings>  
</configuration>

But remove is not working here. How can I override mykey1 without breaking mykey2? add works in this case. I can get myvalue3 from ConfigurationManager.

EDIT: general.config is copied to output folder automatically when compiling. Don’t worry about the path issue. Currently I got:

ConfigurationManager.AppSettings["mykey1"] 
     //I got "myvalue1", but I want "anothervalue" here
     //that is, this item is "overrided", just like virtual methods in C#
ConfigurationManager.AppSettings["mykey2"] 
     //this setting will not be modified, currently it works fine
ConfigurationManager.AppSettings["mykey3"]   //good 
  • 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-23T11:18:15+00:00Added an answer on May 23, 2026 at 11:18 am

    MSDN helps to answer the question:

    You can use the file attribute to
    specify a configuration file that
    provides additional settings or
    overrides the settings that are
    specified in the appSettings element.
    You can use the file attribute in
    source control team development
    scenarios, such as when a user wants
    to override the project settings that
    are specified in an application
    configuration file. Configuration
    files that are specified in a file
    attribute must have the appSettings
    element rather than configuration
    element as the root node.

    So, the settings in your general.config will override items in app.config. This is the opposite of what you want (to have app.config items override general.config items). You will have to resolve this issue in C# code (it will inevitably look ugly).

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

Sidebar

Related Questions

I have a php file that looks like this: <?php include(config.php); // put the
I have an application config file that looks something like this: database: type: [db-type]
I have a config.php file that creates an array, something like $config = array(
I have a config file that I read using the RawConfigParser in the standard
I have a large config file (user) that i needed to go to the
I have set an array in my config file that I use global in
I have some configuration data in a config file that I read off disk
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have an service application that reads a config file containing a list of
I have a web application that is deployed with web.config file. Are there any

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.