Skip to content
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

.NET 9 breaks SaveWindowPosition #4541

Open
Suplanus opened this issue Jan 29, 2025 · 0 comments
Open

.NET 9 breaks SaveWindowPosition #4541

Suplanus opened this issue Jan 29, 2025 · 0 comments
Labels

Comments

@Suplanus
Copy link

Describe the bug

If SaveWindowPosition = true in the MetroWindow and TargetFramework = net9.0-windows the application throws an exception on closing and not saving the window position:

ZH.TED.Test.WPF Error: 0 : MahApps.Metro.Behaviors.WindowsSettingBehavior: The settings could not be saved! System.Configuration.ConfigurationErrorsException: Failed to save settings: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
 ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
 ---> System.InvalidOperationException: An unexpected error occurred in 'ClientConfigurationHost::OpenStreamForWrite '' '''.
   at System.Configuration.ClientConfigurationHost.OpenStreamForWrite(String streamName, String templateStreamName, Object& writeContext)
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
   --- End of inner exception stack trace ---
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
   --- End of inner exception stack trace ---
   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 MahApps.Metro.Behaviors.WindowsSettingBehavior.SaveWindowState()

Steps to reproduce

Here is an example project:
ZH.TED.Test.WPF.zip

If you switch to net8.0-windows as TargetFramework, it works as expected.

Environment

MahApps.Metro version: 2.4.10
Target Framework: .Net 9 (9.0.100)
@Suplanus Suplanus added the Bug label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant