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...
<?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...