HOW TO: read configuration information from a component's .config file

Topics: General discussion
Jul 28, 2010 at 3:32 PM


I am building a component in 3.5 (to be ported to 4.0 for the next release) that needs to read some configuration information from it's own config file.

This component is shared across multiple applications and while we can store the config information in each app's config file, I am thinking it would be more maintainable if they were kept in one place (i.e. the component's config file).

I know that by default the component reads from the invoking app's config file and there are possibly very good reasons for why this is so. But in this specific case, I would like to see if there is any way to over ride this functionality.

The component does not have data access (for various business reasons that are beyond my power to influence) so I cannot retrieve and cache the settings from a database.

After some googling, I found this - but wanted to see if there was any way to do it from within .NET.

Thanks a lot in advance,


Jul 29, 2010 at 8:08 AM


I'm not sure if I understand your question correctly, please let me know. Basically, what you would want is to have an external common configuration file (component's config file) that can be read by multiple application that referencing your component, is that right? If yes, check this blog and see if approaches like using FileConfigurationSource or ConfigSource will fit for your needs.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.


Jul 30, 2010 at 3:23 AM


That works, thanks...