自定义配置处理程序例外

时间:2013-02-03 18:46:37

标签: vb.net web-config

我正在尝试使用以下网页上的信息在web.config中创建自定义配置部分:http://msdn.microsoft.com/en-gb/library/ms228056.aspx

以下是代码:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Dim config As Hashtable = DirectCast(System.Configuration.ConfigurationManager.GetSection("myCustomGroup/myCustomSection"), Hashtable)
        Catch ex As Exception

        End Try
    End Sub

这是web.config:

<configuration>
    <!-- Other configuration settings, like <system.web> -->
        <configSections>
            <sectionGroup name="myCustomGroup">
                <section name="myCustomSection" type="MyConfigSectionHandler.MyHandler, MyCustomConfigurationHandler"/>
            </sectionGroup>
            <!-- Other <section> and <sectionGroup> elements. -->
        </configSections>

      <!-- Configuration section settings area. -->
      <myCustomGroup>
        <myCustomSection myAttrib1="Clowns">
          <myChildSection
              myChildAttrib1="Zippy"
              myChildAttrib2="Michael Zawondy "/>
        </myCustomSection>
      </myCustomGroup>
</configuration>

MyHandler.vb可以在网页上找到,所以我不会在这里粘贴代码。我遇到了一个例外:{"An error occurred creating the configuration section handler for myCustomGroup/myCustomSection: Could not load type 'MyConfigSectionHandler.MyHandler' from assembly 'MyCustomConfigurationHandler'. (C:\Users\Ian\Desktop\WebSite3\web.config line 13)"}

网上有类似的问题(例如这里:http://csd.codeplex.com/discussions/234031),回答者建议在Section Group Type元素中没有指定程序集名称,但在我的情况下是。为什么我看到这个例外? MyCustomConfigurationHandler.dll位于网站的bin文件夹中。

0 个答案:

没有答案