views:

121

answers:

1

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>

and

  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 }
    }
  }

and

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"));
          }
        }
      }
    }
  }

project : Web Application ...

I need to find error first . . .

why :

Error message parser: Error creating configuration section handler for FlowWebDataProviders: Could not load type 'FlowWebProvidersSection'.

?

by the way : syntax of nemerle (current language) is very similar C#, don't afraid to read the code... thank you

added : this is how I want to get section

ConfigurationManager.GetSection("FlowWebDataProviders")
+1  A: 

Check your type AND namespace. I.e.

  <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
Ted
if I use "MyNamespace.FlowWebProvidersSection" got error : Provider's Type could not be found (it's on last code in the question) so I guess it founds my class but can't load it :/ no idea why
nCdy