无法加载ConfigurationSection类 - 类型

时间:2010-03-18 06:07:48

标签: .net asp.net nemerle

at web.config

<section name="FlowWebDataProviders" type="FlowWebProvidersSection" requirePermission="false"/>


  <FlowWebDataProviders peopleProviderName="sqlProvider" IzmListProviderName="sqlProvider">
    <PeopleProviders>
      <add name="sqlProvider" type="SqlPeopleProvider" connectionStringName="FlowServerConnectionString"/>
      <add name="xmlProvider" type="XmlPeopleProvider" schemaFile="People.xsd" dataFile="People.xml"/>
    </PeopleProviders>
    <IzmListProviders>
      <add name="sqlProvider" type="SqlIzmListProvider" connectionStringName="FlowServerConnectionString"/>
    </IzmListProviders>
  </FlowWebDataProviders>

  public class FlowWebProvidersSection : ConfigurationSection
  {
    [ConfigurationProperty("peopleProviderName", IsRequired = true)]
    public PeopleProviderName : string
    {
        get { this["peopleProviderName"] :> string }
        set { this["peopleProviderName"] = value; }
    }
    [ConfigurationProperty("IzmListProviderName", IsRequired = true)]
    public IzmListProviderName : string
    {
        get { (this["IzmListProviderName"] :> string) }
        set { this["IzmListProviderName"] = value; }
    }
    [ConfigurationProperty("PeopleProviders")]
    [ConfigurationValidatorAttribute(typeof(ProviderSettingsValidation))]
    public PeopleProviders : ProviderSettingsCollection
    {
        get { this["PeopleProviders"] :> ProviderSettingsCollection }
    }
    [ConfigurationProperty("IzmListProviders")]
    [ConfigurationValidatorAttribute(typeof(ProviderSettingsValidation))]
    public IzmListProviders : ProviderSettingsCollection
    {
        get { this["IzmListProviders"] :> ProviderSettingsCollection }
    }
  }

public class ProviderSettingsValidation : ConfigurationValidatorBase
  {
    public override CanValidate(typex : Type) : bool
    {
         if(typex : object == typeof(ProviderSettingsCollection)) true else false
    }

    /// <summary>
    // validate the provider section    
    /// </summary>
    public override Validate(value : object) : void
    {
      mutable providerCollection : ProviderSettingsCollection = match(value) 
             {
                | x is ProviderSettingsCollection => x
                | _ => null
             }
      unless (providerCollection == null) 
      {
        foreach (_provider is ProviderSettings in providerCollection) 
        {
          when (String.IsNullOrEmpty(_provider.Type)) 
          {
            throw ConfigurationErrorsException("Type was not defined in the provider");
          }
          mutable dataAccessType : Type = Type.GetType(_provider.Type);
          when (dataAccessType == null) 
          {
              throw (InvalidOperationException("Provider's Type could not be found"));
          }
        }
      }
    }
  }

项目:Web应用程序......

我需要先找到错误。 。

为什么:

错误消息解析器:为FlowWebDataProviders创建配置节处理程序时出错:无法加载类型'FlowWebProvidersSection'。

顺便说一下:nemerle(当前语言)的语法与C#非常相似,不要害怕阅读代码......谢谢

补充说:这就是我想要的部分

ConfigurationManager.GetSection("FlowWebDataProviders")

1 个答案:

答案 0 :(得分:1)

检查您的类型和命名空间。即

  <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />