0

我正在尝试使用以下网页上的信息在 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 文件夹中。

4

0 回答 0