Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Configuration Sections

I am currently trying to implement a Custom Configuration Section in a project I am busy with and no matter what I try I keep getting the error below:

{"An error occurred creating the configuration section handler for pageAppearanceGroup/pageAppearance: Could not load type 'Samples.AspNet.PageAppearanceSection' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (E:\Three Nine Developments\lastfm\msdn\msdn\bin\Debug\Samples.Aspnet.vshost.exe.config line 6)"}

I have copied the code from this MSDN Artricle:

http://msdn.microsoft.com/en-us/library/2tw134k3.aspx

I still get the same error.

I have tried the all the advice/guide in the following articles but to no avail.
http://www.evanclosson.com/devlog/bettercustomerrorsinaspnetcustomconfigurationsection

http://geekswithblogs.net/akraus1/articles/64871.aspx

This must be something stupid that I am missing. I am running Vista, could that be a problem? some obscure security setting?

    <configuration>
  <!-- Configuration section-handler declaration area. -->
  <configSections>
    <sectionGroup name="pageAppearanceGroup">
      <section
        name="pageAppearance"
        type="Samples.AspNet.PageAppearanceSection"
        allowLocation="true"
        allowDefinition="Everywhere"
      />
    </sectionGroup>
    <!-- Other <section> and <sectionGroup> elements. -->
  </configSections>

  <!-- Configuration section settings area. -->
  <pageAppearanceGroup>
    <pageAppearance remoteOnly="true">
      <font name="TimesNewRoman" size="18"/>
      <color background="000000" foreground="FFFFFF"/>
    </pageAppearance>
  </pageAppearanceGroup>



</configuration>
like image 744
Gary Woodfine Avatar asked May 13 '09 15:05

Gary Woodfine


People also ask

What is configuration section?

The configuration section is an optional section for programs and classes, and can describe the computer environment on which the program or class is compiled and executed.

How do I create a custom section in app config?

Open the App. config file and add the configSections, sectionGroup and section to it. We need to specify the name and fully qualified type of all the section and section group.

What are the different sections in a web config file?

A . config file contains XML that has a configuration element as the root node. Information inside this element is grouped into two main areas: the configuration section-handler declaration area, and the configuration section settings area.


2 Answers

My guess is that you've copied the code, but you have different assembly names. Posting the config will help.

I would also fully quality your type in the config (something that sample doesn't show). Something like...

<section name="MySection" type="My.Assembly.Type, My.Assembly" />
like image 166
Martin Peck Avatar answered Oct 02 '22 02:10

Martin Peck


You should also check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject.

  • Unraveling the mysteries of .NET 2.0 configuration
  • Decoding the mysteries of .NET 2.0 configuration
  • Cracking the mysteries of .NET 2.0 configuration

Highly recommended, well written and extremely helpful!

Marc

like image 26
marc_s Avatar answered Oct 02 '22 02:10

marc_s