I recently started using IConfigurationSectionHandler as a custom configuration section for my BL DLL. I’m using it inside web.config files to pass settings values to the BL DLL.
While it reads the local web.config perfectly, the problem is reading a global configuration file (root web.config) that consists of shared settings.
How can I manage to do that using IConfigurationSectionHandler?
To properly answer your question we would probably need to see some code from you custom section handler.
However, one point that immediately springs to mind, is that you might not be correctly using the
parentargument that is being passed into your handler.Just to get our terminoligy on the same page, I will refer to the ‘Create’ method which is your implementation of the
IConfigurationSectionHandler.Create, and aconfiguration objectwhich is the object that you return from the ‘Create’ method.Very simplistically, your section handlers
Createmethod should be invoked for each occurance of your custom section in the hierarchy of web.config files. With each invocation, previous configuration object that you returned fromCreateis passed into the next call as theparentargument, of course the first call will have anullparent which indicates that you need to create this initial ‘configuration object’, subsequent calls should not create a newconfiguration object but add to or modify the one passed in as the parent.The end result is that when you read the configuration from the file you receive a ‘configruation object’ that contains the sum of the settings from all levels.
NB: You should really be using ConfigurationSection, since IConfigurationSectionHandler has been deprecated since Framework 2.0. Here is a link to using this class.
http://msdn.microsoft.com/en-us/library/2tw134k3.aspx