Witam. Mam problem z odczytem pliku user.config. Zapisuję w nim właściwości w ten sposób:
System.Configuration.SettingsProperty property = new System.Configuration.SettingsProperty(a.Name);
property.DefaultValue = true;
property.IsReadOnly = false;
property.PropertyType = typeof(bool);
property.Provider = AppSettings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(System.Configuration.UserScopedSettingAttribute), new System.Configuration.UserScopedSettingAttribute());
AppSettings.Default.Properties.Add(property);
AppSettings.Default[a.Name] = a.IsChecked;
AppSettings.Default.Save();
Plik po takim zapisie plik wygląda mniej więcej tak:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<userSettings>
<testapp.Properties.AppSettings>
<setting name="fefkr" serializeAs="String">
<value>False</value>
</setting>
</testapp.Properties.AppSettings>
</userSettings>
</configuration>
Problem w tym, że taka linijka po ponownym uruchomieniu programu wywala wyjątek, że niby nie znaleziono "fefkr":
bool b = (bool)AppSettings.Default[a.Name];
Wie ktoś o co może chodzić? Z góry dzięki za pomoc ;)