Declaring custom configuration section.

  • Thread starter Thread starter Mauricio
  • Start date Start date
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????
 
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.
 
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????
 
Back
Top