Bayern
Bayern

Reputation: 350

Using the App.config file out of a shared project

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!

Upvotes: 0

Views: 769

Answers (1)

Oliver
Oliver

Reputation: 9002

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.

Upvotes: 1

Related Questions