Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET/ASP.NET 4.0 custom configuration section: "An error occurred creating the configuration section handler"
    text
    copied!<p>I am creating a custom config section that will allow me to manage what ELMAH exceptions I want to ignore from my VB.NET/ASP.NET app. Here's my code. I made it easy to paste in a blank code file if anyone's up to the challenge of diagnosing the problem.</p> <pre><code>Imports System.Configuration Namespace ElmahExceptionHandling Public Class IgnoredExceptionSection : Inherits ConfigurationSection &lt;ConfigurationProperty("IgnoredExceptions")&gt; ReadOnly Property IgnoredExceptions As IgnoredExceptions Get Return TryCast(Me("IgnoredExceptions"), IgnoredExceptions) End Get End Property Shared Function GetConfig() As IgnoredExceptionSection Return TryCast(System.Configuration.ConfigurationManager.GetSection("IgnoredExceptionSection"), IgnoredExceptionSection) End Function End Class &lt;ConfigurationCollection(GetType(IgnoredException))&gt; Public Class IgnoredExceptions : Inherits ConfigurationElementCollection Protected Overloads Overrides Function CreateNewElement() As System.Configuration.ConfigurationElement Return New IgnoredException End Function Protected Overrides Function GetElementKey(element As System.Configuration.ConfigurationElement) As Object Return TryCast(element, IgnoredException).Message End Function End Class Public Class IgnoredException : Inherits ConfigurationElement &lt;ConfigurationProperty("Message")&gt; ReadOnly Property Message As String Get Return Me("Message") End Get End Property End Class End Namespace </code></pre> <p>And here's the config:</p> <pre><code>&lt;configSections&gt; &lt;section name="IgnoredExceptionSection" type="ElmahExceptionHandling.IgnoredExceptionSection, WEB" /&gt; &lt;/configSections&gt; &lt;IgnoredExceptionSection&gt; &lt;IgnoredExceptions&gt; &lt;add Message="test exception" /&gt; &lt;/IgnoredExceptions&gt; &lt;/IgnoredExceptionSection&gt; </code></pre> <p>When I execute this code:</p> <pre><code>Dim section As ElmahExceptionHandling.IgnoredExceptionSection = ConfigurationManager.GetSection("IgnoredExceptionSection") </code></pre> <p>I get the error <code>An error occurred creating the configuration section handler for IgnoredExceptionSection: Could not load file or assembly 'WEB' or one of its dependencies.</code>.</p> <p>What boggles my mind is that this all works fine in my C# console test app after I convert the code from VB.NET using a web utility. However, when I paste the VB code from my web app into my VB.NET console test app, it doesn't work there, either, so it appears to be a C#/VB issue. What am I doing wrong here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload