How to avoid duplicate settings when using 2 projects and 2 testing projects in Visual Studio?


Following my <a href="https://stackoverflow.com/questions/484087/how-to-avoid-duplicate-app-config-using-visual-studio-2008-unit-testing" rel="nofollow">previous question</a>, now I have 2 projects: one Console Project and a Library Project. They also have their respective unit test projects. When I run a test for the console project that uses a method from the library project and the library project needs an app.config setting, that setting must be in the console test project's app.config. What I have to do to make it read the setting from the library project app.config, so then I do not have to duplicate the setting across multiple app.config?

<strong>Update</strong> I don't want to use the same App.Config for both projects. What I am having to do now, but don't want to do anymore, is copying all the library app.config settings into the console project settings.


If the library project is a class library, then it needs a context to execute in. VS will not read the app.config file for a class library, it only reads the app.config file from the executing context, from what I can tell. The setting has to be in the console app.config because that is the context for execution. If you are running unit tests and they are the executing context then they will need their own app.config as well.


One option I have used is to share the config file via a soft link. First create the app.config file in one project, then add it to the other:

<ol><li>Right-click the other project.</li> <li>Select Add -> Existing Item and navigate to thh app.config.</li> <li>Don't click Add! Click the little arrow on the right side of the button, and select Add as Link.</li> </ol>

This of course assumes you can use the same file for both projects.

UPDATE: I do not know which part of the app.config you need to share. But for the appSettings section, you can include the contents of another file via the "file" attribute.

<appSettings file="commonSetting.config">


Maybe something similar can be used in your case?


  • file read() const correctness
  • C++ stl pop doesn't return [closed]
  • How to protect the mp3 file from read or copy on Android?
  • Enable Bootstrap Intellisense using Angular 4 in WebStorm
  • How to remove last utf8 char of a python string
  • Merge list of objects into consistent list based on common matching attribute in Python
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Buffer a large file; BufferedInputStream limited to 2gb; Arrays limited to 2^31 bytes
  • Insert records if not exist SQL Server 2005
  • Converter from SAT to 3-SAT
  • Unique Permutations - with exceptions
  • Cloud Code function running twice
  • CERN ROOT exporting data to plain text
  • jQuery: add elements until a particular height is reached
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Android screen density dpi vs ppi
  • req.body is undefined - nodejs
  • Bug in WPF DataGrid
  • Symfony2: How to get request parameter
  • Akka Routing: Reply's send to router ends up as dead letters
  • Return words with double consecutive letters
  • Invalid access key error using credentials redeemed from an amazon open id token
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Understanding cpu registers
  • coudnt use logback because of log4j
  • LevelDB C iterator
  • Add sale price programmatically to product variations
  • Can't mass-assign protected attributes when import data from csv file
  • Reading document lines to the user (python)
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal