8

I have a two projects under one solution, and I need to share a app.config file between them . mostly they use the same parameters from the configuration.

Is there some way to share the config file ? I am using VS2010.

Night Walker
  • 20,638
  • 52
  • 151
  • 228
  • Possible duplicate of [How to Share App.config?](http://stackoverflow.com/questions/426245/how-to-share-app-config) – AXMIM Oct 13 '15 at 19:47

2 Answers2

14

Yes, just add the file from the other project 'as a link': Right click on the project >> select 'Add existing file' >> navigate to the app.config file >> click the dropdown next to the 'add' button and select 'add as a link'.

Teoman Soygul
  • 25,584
  • 6
  • 69
  • 80
  • But how I can use it from the code ? When I try to use it like ConfigurationManager.ConnectionStrings["SimulatorDB"].ConnectionString I am getting an null exception – Night Walker Jun 30 '11 at 11:20
  • Oh I see that now you're trying to share _portions_ of app.config between projects. To achieve that, see this question here: http://stackoverflow.com/questions/2746797/c-can-we-share-some-contents-of-app-config-between-projects . But in this case, you'll need to separate app.config files while one's sections pointing to the other (externalized) app.config file. – Teoman Soygul Jun 30 '11 at 12:04
  • @Teoman Soygul , If I not going to use it, why will I add a reference to a app.config file :) – Night Walker Jul 01 '11 at 08:09
  • getting error - --------------------------- Microsoft Visual Studio --------------------------- Cannot add a link to the file App.config. There is already a file of the same name in this folder. --------------------------- OK --------------------------- – Neo Oct 04 '16 at 05:59
3

see http://support.microsoft.com/kb/555396

Hope this helps

jaywayco
  • 5,846
  • 6
  • 25
  • 40