.NET Zone is brought to you in partnership with:

I’ve been a Windows developer since 3.0 and caught the Visual Basic wave early with v1. I’ve released a “production” application in every version of VB since then (except VB for DOS). Focusing on enterprise, line-of-business development I’ve built Call Center Applications, Mortgage finance systems, Customer Relationship Management tools and more recently I’ve been in the Litigation Support/Electronic Data Discovery/Electronically Stored Information space. Greg is a DZone MVB and is not an employee of DZone and has posted 269 posts at DZone. You can read more from them at their website. View Full User Profile

Shared and External App.Config Settings

05.27.2012
| 2063 views |
  • submit to reddit

MECUM – .NET TECHNOLOGY BLOG - Daily Problems – Sharing One App.config With Multiple Class Libraries, Assemblies

You create a project and you want to share a single app.config during development, with different class libraries and one executable.

Here is a simple solution. You create a simple assembly (class library type project) and add a static class to it, which offers you the access to the app.config of the current application that executes the loaded class-library:

image

The Wit and Ramblings of David Giard - Moving Config Sections to External Files

An App.config file or a Web.config file are great places to store configurable information – information that generally doesn’t change; but we want to be able to change easily (i.e., without rebuilding and redeploying the application.) Examples include connection strings (stored in the config file’s <connectionStrings> section) and application-wide name-value pairs (stored in the config file’s <appSettings> section).

We can add more flexibility by moving a section to an external file and linking to that file from the config file.

By splitting the file, we can manage and deploy only those settings separate from the rest of the configuration.

To do so, we create a new text file and copy that section into that file; then use the configSource attribute of the section tag in the original config file to point to the new file.

For example, the following app.config contains all the application’s connection strings and application settings

...

image..."

Now if only we could combine these two.

Published at DZone with permission of Greg Duncan, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)