내 응용 프로그램에 대한 사용자 지정 구성 섹션을 만들었습니다. 어떤 이유로 Visual Studio 2010에서 사용자 지정 속성을 선택할 수 없습니다. 나는 모든 "추가"키에 대해 다음과 유사한 경고를 받고 있어요 :App.Config 사용자 지정 구성 섹션 문제가 발생했습니다.
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; }
}
}
}
응용 프로그램에서 사용할 수 있습니까? 내 말은, 단지 시간 경고를 컴파일하는 것입니까, 아니면 응용 프로그램에서 사용할 수없는 것입니까? – decyclone
UrlFilterCollection serviceConfigSection = ConfigurationManager.GetSection ("urlFilterSection")을 UrlFilterCollection으로 사용합니다. 반환 ... – timothyclifford