views:

282

answers:

2

Is it possible to use the .NET configuration objects to get at .config files specified for a class library assembly rather than the executable assembly.

For example:

I'm working on a .net port of Concordion and I would like to have options that are specific to Concordion itself but there are also options that are specific to each specification assembly that Concordion calls. I would like the Concordion options to be in one .config file while the specification assemblies each have their own .config files (where the schema of each of these config files is the same).

I can do it right now by writing my own parsing logic but if there is something already built in .NET I would prefer to use that. Right now, as far as I know, it is only possible to have a single .config file for the executable assembly.

+2  A: 

You should definitely check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject.

* Unraveling the mysteries of .NET 2.0 configuration
* Decoding the mysteries of .NET 2.0 configuration
* Cracking the mysteries of .NET 2.0 configuration

Highly recommended, well written and extremely helpful! He shows how to create and use custom configuration sections, and goes on to explain how to use your own custom.config instead of or in addition to standard .NET config files.

Marc

marc_s
i must admit and confirm, Jon Rista's articles @codeproject is what you need the read!
Christian
+1  A: 

Look at ConfigurationManager.OpenMappedExeConfiguration(). It allows you to supply the name of the configuration file you want to open. The example there should set you on your way.

Harper Shelby