By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

Mulitp app.config files in multiple project solution

P: n/a
Sam
Hi All,

I have a solution which consists of multiple projects and each of these
projects has their own app.config file. The problem is that all of my
projects in the solution pull keys from the app.config file from the main
project (my start-up project). My question is can each project look for its
keys in its own config file first? Is there something or settings that
missing here? Would some one give me a hand?

Regards,

Sam
Jun 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
By "a solution which consists of multiple projects" I guess you mean
multiple class libraries. Any App.config file added to a class lib
won't get "built" to the output directory
in the same way that it does when added to a console or windows
application (at least this is true in .net 1.1, I don't know about .net
2.0)

If you want to have multiple config files then you will need to write
custom code for this and make sure that the configuration files get
copied to the right place at build time.

I have done something similar and have used NAnt to rename and copy the
app.config files and then used custom code to read from the xml config
files. However, there is a lot of clever stuff about config files in
..NET 2.0 that might be useful.

Jun 23 '06 #2

P: n/a
Sam
Hi Sam,

Sorry I should have clarified a bit more when I said "a solution which
consists of multiple projects". Your guess is correct. What I thought is
that if I can use each app.config for each of my class lib project, then the
code would look much cleaner and readable. But most importantly, if someone
in development team wants to use this project in the future, he wouldn't
have to spend time look for the keys. Thanks so lot for your help.

Regards,

another Sam
"sam.m.gardiner" <sa************@gmail.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
By "a solution which consists of multiple projects" I guess you mean
multiple class libraries. Any App.config file added to a class lib
won't get "built" to the output directory
in the same way that it does when added to a console or windows
application (at least this is true in .net 1.1, I don't know about .net
2.0)

If you want to have multiple config files then you will need to write
custom code for this and make sure that the configuration files get
copied to the right place at build time.

I have done something similar and have used NAnt to rename and copy the
app.config files and then used custom code to read from the xml config
files. However, there is a lot of clever stuff about config files in
.NET 2.0 that might be useful.

Jun 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.