1

I have several projects and a website in a large asp.net solution. In some of projects I have an app.config file and in the website I have my web.config. In each config I specify several things that are common amongst them, such as connection strings. Is there any way to consolidate these common items into one config file and reference that from the various projects that need them?

2 Answers 2

1

You can reference external config files in any .config (see http://www.peterprovost.org/blog/post/External-Config-Files-in-NET.aspx).

Each project has a config file; these files get published to the bin directory as [output name].config (e.g., MyCode.DLL, MyCode.DLL.config). You can then reference these .config files from your main config (web.config).

If you find your config files aren't finding their way to the correct destination, you can do the post compilation step that ChanChan mentioned.

Sign up to request clarification or add additional context in comments.

Comments

1

You can do this with a pre/post compile step in the project to copy the config file from say the solution directory.

A few years back, this was the solution that was recommended by scott hanselman.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.