Declaring custom configuration section.

M

Mauricio

Hí!

I´m implementing a web application using the Front
Controller pattern described in the Enterprice Solutions
Patters using Microsoft .NET v 1.0

In order to map an absolute path to another URL, an
UrlMap class is implemented. This class implements the
IConfigurationSectionHandler interface.

The mapping is defined in the Web.config file as shown:

<controller.mapping>
<entries>
<entry key="/patterns/frontc/3/Page1.aspx"
url="ActualPage1.aspx" />
<entry key="/patterns/frontc/3/Page2.aspx"
url="ActualPage2.aspx" />
</entries>
</controller.mapping>

Then, I defined a custom section for "controller.mapping"

<configSections>
<section name="controller.mapping"
type="UrlMap" />
</configSections>

UrlMap uses the followin method to access the custom
section.
ConfigurationSettings.GetConfig("controller.mapping");

But when I try to run my application, it´s raised the
following error:

Parser Error Message: Exception creating section handler.

Line 3:
Line 4: <configSections>
Line 5: <section name="controller.mapping"
type="Volvo.Evaluacion.Web.UrlMap" />
Line 6: </configSections>
Line 7:

I don´t know if my custom section is well declared. Can
anyone help me????
 
J

John Saunders

Mauricio,

I believe you may need to name your assembly in your <section type>
attribute, and put the assembly where it can be found (or in the GAC). Look
at %WINDIR%\Microsoft.Net\Framework\<version>\CONFIG\machine.config for
examples.
 
J

Jerry III

The type attribute in you section declaration must be a class implementing
IConfigurationSectionHandler and will allow you to access the section, not
the class that will be using the section.

Jerry

Hí!

I´m implementing a web application using the Front
Controller pattern described in the Enterprice Solutions
Patters using Microsoft .NET v 1.0

In order to map an absolute path to another URL, an
UrlMap class is implemented. This class implements the
IConfigurationSectionHandler interface.

The mapping is defined in the Web.config file as shown:

<controller.mapping>
<entries>
<entry key="/patterns/frontc/3/Page1.aspx"
url="ActualPage1.aspx" />
<entry key="/patterns/frontc/3/Page2.aspx"
url="ActualPage2.aspx" />
</entries>
</controller.mapping>

Then, I defined a custom section for "controller.mapping"

<configSections>
<section name="controller.mapping"
type="UrlMap" />
</configSections>

UrlMap uses the followin method to access the custom
section.
ConfigurationSettings.GetConfig("controller.mapping");

But when I try to run my application, it´s raised the
following error:

Parser Error Message: Exception creating section handler.

Line 3:
Line 4: <configSections>
Line 5: <section name="controller.mapping"
type="Volvo.Evaluacion.Web.UrlMap" />
Line 6: </configSections>
Line 7:

I don´t know if my custom section is well declared. Can
anyone help me????
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top