Accessing another projects app.config properties?

user1352057 picture user1352057 · Apr 1, 2014 · Viewed 35.7k times · Source

I have two projects within my solution, for this example I will call them project A and B.

Project B references A. Can Project B access the app.config properties of project A?

I wish to access an app key string within the app.config of A.

string tfsUri = ConfigurationManager.AppSettings["TfsUri"];

Answer

oleksii picture oleksii · Apr 1, 2014

That's generally not a good idea, as you introduce hard dependencies between the projects. So if you can copy-paste config value, that will make your projects self-contained (however, this introduces duplication of config value).

You can also automate this, so that when you build a project the configuration dependency is automatically resolved.

Having-said this, there are other options, and in each case you may prefer to use something else. Your other options are: