의 ConfigSection 여기 ConfigurationManager.GetSection는 SectionGroup이는 web.config 파일 여기</p> <p>관련되어 appparently 올바른 '경로'
<configSections>
<sectionGroup name="HttpExceptionHandler">
<section name="errorLog" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="errorMail" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
을 널 (null)을 것 것 반환 :
<HttpExceptionHandler>
<errorLog type="MI.Generic.HttpExceptionHandler.SqlErrorLog, MI.Generic.HttpExceptionHandler" dataSource="opentraderdev\dev" initialCatalog="MiTraderError" />
</HttpExceptionHandler>
코드는 다음과 같습니다.
public class ErrorLogConfiguration : ConfigurationSection
{
public static ErrorLogConfiguration GetConfig()
{
return ConfigurationManager.GetSection("HttpExceptionHandler\\errorLog") as ErrorLogConfiguration;
}
[ConfigurationProperty("initialCatalog", IsRequired = true)]
public string InitialCatalog
{
get
{
return this["initialCatalog"] as string;
}
}
[ConfigurationProperty("dataSource", IsRequired = true)]
public string DataSource
{
get
{
return this["dataSource"] as string;
}
}
}
반환 값은 항상 null입니다. 나는 아이디어가 부족하다. 어떤 도움을 주셔서 감사합니다.
Windows 디렉토리가 아니므로 다른 슬래시를 사용하십시오 :) – terR0Q