<configuration>
<configSections>
<sectionGroup name="loggingConfigs">
<section name="LoggingParameters"
type="Framework.Logging.LoggingParameters, Framework.Logging" />
</sectionGroup>
</configSections>
<loggingConfigs>
<LoggingParameters
myconfig="C:mydir\mypath1\mypath2\log4net.config"
/>
</loggingConfigs>
</configuration>
public class LoggingParameters : ConfigurationSection
{
[ConfigurationProperty("myconfig", IsRequired = true)]
private string ConfigFileLoc
{
get { return (string)this["myconfig"]; }
}
public FileInfo MyConfigFile
{
get
{
string s = ConfigFileLoc; <--- getting empty string here..don't know why
return new FileInfo(s);
}
}
}
当我在我的应用程序的其他地方进行以下调用时,
FileInfo f = new Framework.Logging.LoggingParameters().MyConfigFile;
ConfigFileLoc 总是返回空白。我不知道为什么它是空白的..为什么字符串是空的..请帮忙。