Exception in configuration section handler using a Custom ConfigurationHandler

M

murl

Below is what i have as the custom section in the web.config file...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<!-- register local configuration handlers -->
<configSections>
<sectionGroup name="cbsoffice">
<section name="data"
type="CbsOffice.ProviderConfigurationHandler,CbsOffice"/>
</sectionGroup>
</configSections>

*******************************************************
***Customer web.config section*************************
<cbsoffice>
<data defaultProvider="SqlDataProvider">
<providers>
<add name = "SqlDataProvider"
type = "CbsOffice.Data.SqlDataProvider,
CbsOffice.SqlDataProvider"
connectionString =
"Server=(local);Database=CbsOffice;uid=;pwd=;"
providerPath =
"..\Providers\DataProviders\SqlDataProvider\"
objectQualifier = "_"
databaseOwner = "dbo"
/>
</providers>
</data>
</cbsoffice>

The Connection handler is below...
public class ProviderConfigurationHandler :
IConfigurationSectionHandler
{
public object Create(object parent, object configContext, XmlNode
section)
{
ProviderConfiguration providerConfig=new ProviderConfiguration();
providerConfig.LoadValuesFromConfigurationXml(section);
return providerConfig;
}
}

The above function goes through the attributes of the dataprovider
section and puts them into a hashtable..however when calling the
function:
public static ProviderConfiguration GetProviderConfiguration(string
providerName)
{
return (ProviderConfiguration)ConfigurationSettings.GetConfig("cbsoffice/"+providerName);
-> equal to "cbsoffice/data"
}

It throws the Exception in configuration section, as if its not
finding the data object at all...
 
G

Guest

Hey Murl,
I think that you need to add your custom handler to the web config. I'm
doing some testing right now and I hope to figure this out with you.

<system.web>
<httpHandlers>
<!-- Handlers-->
<add verb="*" path="pathToTheFile"
type="ProjectName.MyHandler, ProjectName" />
</httpHandlers>
</system.web>

Late...
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top