Mulitp app.config files in multiple project solution

S

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
 
S

sam.m.gardiner

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.
 
S

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top