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>
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.
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.
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.
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" />
You should also check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject.
Highly recommended, well written and extremely helpful!
Marc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With