473,385 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Exception in configuration section handler using a Custom ConfigurationHandler

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,CbsOf fice"/>
</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(sect ion);
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.GetCo nfig("cbsoffice/"+providerName);
-> equal to "cbsoffice/data"
}

It throws the Exception in configuration section, as if its not
finding the data object at all...
Nov 18 '05 #1
2 3191
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
"murl" wrote:
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,CbsOf fice"/>
</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(sect ion);
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.GetCo nfig("cbsoffice/"+providerName);
-> equal to "cbsoffice/data"
}

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

Nov 18 '05 #2
Scratch that last reply :). You have that code taking care of already.

Sorry.

"murl" wrote:
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,CbsOf fice"/>
</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(sect ion);
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.GetCo nfig("cbsoffice/"+providerName);
-> equal to "cbsoffice/data"
}

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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PJdotnet | last post by:
Hi, I'm trying to use out of the box "XmlSerializerSectionHandler" section handler (without doing any custom section handler devlopment) and although I've gone thruogh all the CMAB documentation...
0
by: Jill Graham | last post by:
Hi, I need a list of all the section names within a given sectionGroup defined in the web.config file. Is there a way to get this list using vb.net code ? Example : <configSections>...
1
by: Shaun | last post by:
Hi, I created a custom Section handler using System.configuration for Web application to read from Web.Config File. If I want to use the same handler to read from app.config file: app.config is...
1
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a...
0
by: thehitman | last post by:
I used an article "Creating a Flexible Configuration Section Handler "(http://www.15seconds.com/issue/040504.htm). The Console application works with app.config but with the web.config. The...
1
by: =?Utf-8?B?QnJldHQgT3NzbWFu?= | last post by:
I'm trying to set up a custome e-mail publisher for a web app using the Microsoft Exception Management Application Block for .NET sample app. Our app already uses the Exception Management Block,...
1
by: =?Utf-8?B?RGljaw==?= | last post by:
My Windows Application stores its configuration values in app.config and these are typed and accessed via corresponding classes, something like this... <configSections> <section name="Watcher"/>...
7
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.