New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowSettings.SaveWindowState ConfigurationErrorsException #3131

Closed
xmedeko opened this Issue Dec 22, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@xmedeko

xmedeko commented Dec 22, 2017

We have rare error logs from our users, that saving of the window state crashes the whole application.

ConfigurationErrorsException: Failed to save settings: It is an error to use a section registered as allowExeDefinition='MachineToRoamingUser' beyond the roaming user config, in the local user config. 
...
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 MahApps.Metro.Controls.WindowSettings.SaveWindowState() at MahApps.Metro.

We do not have defined any MahApps section in our App.config. The section MahApps.Metro.Controls... is added at runtime. It has allowExeDefinition="MachineToLocalUser" on my computer and I guess on most other users has the same. I guess some users must have configured their system to use MachineToRoamingUser by default. Or may it be caused by some changes in the system and upgrade of the settings?

Can you explicitly set AllowExeDefinition="MachineToLocalUser" in the code? Or may the Save() method be enclosed in try catch?
Thanks

  • MahApps.Metro 1.5.0
  • .NET 4.5.2 or higher
  • OS Vista or higher
    I'm sorry do not know exact OS and .NET version.

@punker76 punker76 added this to the 1.6.0 milestone Jan 13, 2018

@punker76

This comment has been minimized.

Member

punker76 commented Jan 13, 2018

@xmedeko The WindowSettings is marked as obsolete in 1.6.0 and will not be used anymore. It's now all at the WindowsSettingBehaviour. The Save method is enclosed in a try catch.

try
{
settings.Save();
}
catch (Exception e)
{
Trace.TraceError($"{this}: The settings could not be saved! {e}");
}

@punker76 punker76 closed this Jan 13, 2018

@punker76 punker76 added the Bug label Feb 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment