App.Config Проблема с настраиваемым разделом конфигурации

Я создал специальный раздел конфигурации для своего приложения. По какой-то причине Visual Studio 2010 не использует мои настраиваемые свойства. Я получаю похожие предупреждения для всех "добавить" ключи:

Could not find schema information for the element 'urlFilterSection'

ФАЙЛ КОНФИГУРАЦИИ:

<configSections>
    <section name="urlFilterSection" type="BotFinderApp.Models.UrlFilterSection, BotFinder" />
</configSections>

<urlFilterSection>
    <urlFilterCollection>
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
        <add url="urlhere.com.au" numberOfIpsToExtract="10" />
    </urlFilterCollection>
</urlFilterSection>

UrlFilterSection:

namespace BotFinderApp.Models
{
    public class UrlFilterSection : ConfigurationSection
    {
        public UrlFilterSection()
        {    
        }

        [ConfigurationProperty("urlFilterCollection", IsDefaultCollection = false)]
        [ConfigurationCollection(typeof(UrlFilterCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
        public UrlFilterCollection Urls
        {
            get
            {
                var urlsCollection = (UrlFilterCollection)base["urlFilterCollection"];
                return urlsCollection;
            }
        }
    }
}

UrlFilterCollection

namespace BotFinderApp.Models
{
    public class UrlFilterCollection : ConfigurationElementCollection
    {
        public UrlFilterCollection()
        {
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new UrlFilter();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((UrlFilter)element).Url;
        }
    }
}

UrlFilter

namespace BotFinderApp.Models
{
    public class UrlFilter : ConfigurationElement
    {
        public UrlFilter()
        {
        }

        [ConfigurationProperty("url", DefaultValue = "", IsRequired = true)]
        public string Url
        {
            get { return (string)this["url"]; }
            set { this["url"] = value; }
        }

        [ConfigurationProperty("numberOfIpsToExtract", DefaultValue = "0", IsRequired = true)]
        public int NumberOfIpsToExtract
        {
            get { return (int)this["numberOfIpsToExtract"]; }
            set { this["numberOfIpsToExtract"] = value; }
        }
    }
}
5
задан timothyclifford 14 December 2010 в 05:55
поделиться