Handling of App.config Files in Solution with some Subprojects

  • Thread starter Thread starter Barney Gumble
  • Start date Start date
B

Barney Gumble

Hi all.
I'd like to get deeper into details of project layout in visual studio. And
maybee someone finds it interesting ...
I've got a project with the following layout just theoretical:

Solution:
- Project Network (DLL) with app.config (some links to Webservices and so
on)
- Project Database (DLL) with app.config (ConnectionStrings and so on)
- Project TestExecutable(Exe) with app.config (some Logging entries or so)

When I build that solution I get just on config file in the bin/Debug
folder: "TestExecutable.Exe.config"

The settings in the other files are compiled into the DLLs and thanks to
Lutz Roeder I can find it there in the CompilerGenerated internal sealed
class Settings.
Hmmm, so far so good, but ...
When I like to change that value I have to open the sources, change the
value and rebuild and distribute it.
I made a config file for easy changeing that values ...
Of course a simple workaround would be to put all admin stuff in the
settings file of the Exe and tell every Dll in Constructor their settings.

But I'd like to know whether there's a possibility to do that in a way I got
one .config file per project on filesystem in bin/DEBUG instead of built
into dll?

Maybee someone finds this interesting ...

Bye Barney Gumble
 
In my experience, config files are useless if they are compiled into your
DLL. they can't be read from there. What I do is to use the app.config in the
library projects as a sample configuration, or to document the defaults.
(note that SETTINGS classes do store their defaults in the library resources,
but not in an embedded config file)

Your EXE project will need its own copy of all the child project
configurations. There's no nice way for VS to merge/update the child
configurations. And even if there were, it would piss off a lot of people and
prevent easy code reuse in a lot of situations where different projects need
to override the library configuration in some manner. (It would be nice to
have some sort of VS add-in to help with this)
 
Back
Top