views:

820

answers:

2

How can I share/link App.config or Web.config between multiple projects in a visual studio solution ?

+4  A: 

In the Add Existing Item dialog that you get from Visual Studio's Solution Explorer, you can add a link to another file on disk to the project. In order to do this, you will have to click on the down-arrow on the right side of the Add button and choose Add As Link.

Enrico Campidoglio
+1  A: 

First of all, remember that an App.config, or web.config, is visble to all code running in any project that is a used within the "process" established by the start-up project within a solution... i.e. if your solution has one console app and 5 class libraries, or one WinForms app and 4 class libraries, or one WIndows service and 3 class libraries, or one console app being used as startup project, and another console app being used as a class library, then you have no problem, the configuration app.config and all referenced files, are visible from all of the projects.

Secondly, if you will have two or more separate executable processes running in your solution, (like a windows service as a server, AND a winforms client), then if you want them to share specific config settings, you could put those settings in the machine.config file, although you should be careful in doing this.. and some enterprise server teams frown on it..

Charles Bretana