日期:2014-05-18  浏览次数:20416 次

关于自定义配置节,无法识别
在配置中的代码为
XML code
<configSections>
<section name="customProvider" type="DatabaseProvider.HiSection,DatabaseProvider"/>
      </sectionGroup>
    </configSections>
    <customProvider defaultProvider="SqlHiProvider">
      <providers>
        <add name="SqlHiProvider" type="DataBaseProvider.SqlArticleProvider,DatabaseProvider"></add>
      </providers>
    </customProvider>

然后配置节类为:
C# code
namespace DatabaseProvider
{
    public class HiSection : ConfigurationSection
    {
        /// <summary>
        /// A collection of registered providers.
        /// </summary>
        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get { return (ProviderSettingsCollection)base["providers"]; }
        }

        [StringValidator(MinLength = 1)]
        [ConfigurationProperty("defaultProvider", DefaultValue = "SqlHiProvider")]
        public string DefaultProvider
        {
            get { return (string)base["defaultProvider"]; }
            set { base["defaultProvider"] = value; }
        }
    }
}

在网上查了查,也看了一些实例,跟我写的一样啊,不知为什么不识别,有类似:“Could not find schema information for the element 'customProvider'" 的Message,在程序里读取配置节,也读不出来

------解决方案--------------------
你是05的吧,用了过期的关键字