Keeping configuration confined to other projects

  • Thread starter Thread starter Kevin Lawrence
  • Start date Start date
K

Kevin Lawrence

Hi all

Picture the scene: I have an ASP.Net project and a Class Libary project (both
C#).

My CL project is acting as the middle-tier and I want to store any configuration
that I would normally store in Web.config, in my CL project, the configuration
should IMO be kept in this project as it will only be accessed by this project.

Do I HAVE to store the config in the executing project - ie the ASP.Net project?

HTMS
Thanks
Kev
 
You do have to store it in the executing project. But, of course, there
is nothing preventing you from creating a custom XML file (with an
analogous structure to .config files) and keeping it in the class
library's project directory.

You can even read this custom XML file (using the same semantics as
..config files' ConfigurationSettings object) by instantiating a
System.ConfigurationNameValueSectionHandler, then using its .Create
method (passing null to the fist 2 parameters) to read your Xml node
where the settings are.
 
You do have to store it in the executing project. But, of course,
there is nothing preventing you from creating a custom XML file (with
an analogous structure to .config files) and keeping it in the class
library's project directory.

You can even read this custom XML file (using the same semantics as
.config files' ConfigurationSettings object) by instantiating a
System.ConfigurationNameValueSectionHandler, then using its .Create
method (passing null to the fist 2 parameters) to read your Xml node
where the settings are.

Thanks, I'll do that.

Kev
 
Back
Top