private void EnsureLoaded() { if (_section == null) { //在 WCFServer 下,以下代码不起作用。所以所有属性都暂时只支持只读。 //_configurtaion = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); _section = ConfigurationManager.GetSection("rafy") as RafyConfigurationSection; if (_section == null) { _section = new RafyConfigurationSection(); //throw new InvalidProgramException("配置文件中没有 rafy 配置节,请检查配置文件。"); } } }
private void EnsureLoaded() { if (_section == null) { //在 WCFServer 下,以下代码不起作用。所以所有属性都暂时只支持只读。 //_configurtaion = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); #if NET45 _section = ConfigurationManager.GetSection("rafy") as RafyConfigurationSection; if (_section == null) { _section = new RafyConfigurationSection(); } #endif #if NS2 var rafyRawSection = ConfigurationHelper.Configuration.GetSection("rafy"); if (rafyRawSection == null) { throw new InvalidProgramException("配置文件中没有 rafy 配置节,请检查配置文件。"); } _section = new RafyConfigurationSection(); rafyRawSection.Bind(_section); #endif } }