public Settings.SettingsBase PopulateSettings(Settings.SettingsBase instance) { var type = instance.GetType(); var prefix = type.Name + "."; var props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .Where(x => x.CanWrite); foreach (var pi in props) { try { var value = ConfigurationManager.AppSettings[prefix + pi.Name]; if (value == null) { instance.AddProblem(new ConvertProblem { PropertyName = pi.Name, Exception = new Exception( string.Format("Property [{0}{1}] not found in web.config", prefix, pi.Name)) }); } // convert object to property type var converted = GetConvertedValue(pi, value); pi.SetValue(instance, converted, null); } catch (Exception e) { // silently add convert problem to instance // so you can debug it in runtime instance.AddProblem(new ConvertProblem { PropertyName = pi.Name, Exception = e }); } } return instance; }