0

How can I use the App.config file from a shared project in Visual Studio 2015 C# application?

 ConfigurationManager.AppSettings[pathKey];

This uses the App.config from the project you are in!

Bayern
  • 330
  • 3
  • 20

1 Answers1

1

You could do this by adding an app.config file as a solution item

Right click on solution > Add Item > Application Configuration File

And then add that shared file to required projects as references.

Add Item > Add Existing Item > Add As Link

enter image description here

Ensure that the properties are set to:

Build Action: Content

Copy To Output Directory: Copy if newer

Be aware that when using this method the config file will not be compiled with the name of the assembly - you may have to load the configuration from file.

Oliver
  • 8,794
  • 2
  • 40
  • 60
  • Well I can't select a .config type file when I right click on new item for the solution. – Bayern Apr 02 '17 at 11:54
  • @Bayern in that case you can just call the file app.config and it will take the extension given. – Oliver Apr 02 '17 at 14:03