My application threw an exception when it tried to save some user configuration settings by calling 'Properties.Settings.Default.Save()'.
Code:
Properties.Settings.Default.UserProp = "MyUserValue";
Properties.Settings.Default.Save();
The exception is:
System.Configuration.ConfigurationErrorsException was caught
BareMessage=Failed to save settings: A configuration file cannot be created for the requested Configuration object.
Line=0
Message=Failed to save settings: A configuration file cannot be created for the requested Configuration object.
Source=System
StackTrace:
at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
at System.Configuration.SettingsBase.SaveCore()
at System.Configuration.SettingsBase.Save()
at System.Configuration.ApplicationSettingsBase.Save()
at ETSquare.MainWindow.Eingangsart_Changed(Object sender, RoutedPropertyChangedEventArgs`1 e)
InnerException: System.Configuration.ConfigurationErrorsException
BareMessage=A configuration file cannot be created for the requested Configuration object.
Line=0
Message=A configuration file cannot be created for the requested Configuration object.
Source=System.Configuration
StackTrace:
at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
at System.Configuration.Configuration.SaveAsImpl(String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll)
at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
InnerException:
This problem happens on every Machine. The environment is Windows XP 32-bit andWindows 7 64bit
The application is a WPF-Browser-Application (xbap).
If I put a 'Properties.Settings.Default.Upgrade()' before the save-command,
Code:
Properties.Settings.Default.UserProp = "MyUserValue";
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.Save();
I get
System.ArgumentNullException was caught
Message=Value cannot be null.
Parameter name: path
ParamName=path
Source=mscorlib
StackTrace:
at System.IO.Directory.GetParent(String path)
at System.Configuration.LocalFileSettingsProvider.GetPreviousConfigFileName(Boolean isRoaming)
at System.Configuration.LocalFileSettingsProvider.Upgrade(SettingsContext context, SettingsPropertyCollection properties, Boolean isRoaming)
at System.Configuration.LocalFileSettingsProvider.Upgrade(SettingsContext context, SettingsPropertyCollection properties)
at System.Configuration.ApplicationSettingsBase.Upgrade()
at ETSquare.MainWindow.Eingangsart_Changed(Object sender, RoutedPropertyChangedEventArgs`1 e)
InnerException:
Any idea please. Thanks in advance.