-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Describe the bug
In an Application im using MahApps, and on Windows 11 this Error sometimes occurs.
We had added SaveWindowPosition="False" but it didn't change the behaviour.
We are not trying to access a Window or similar from another Thread. The same code works under Windows 10 without errors.
Steps to reproduce
We can reproduce it by starting the application and leaving it open. Then Log off the user from Windows. Windows shows a message that the application stops the Log off process.
Expected behavior
The Application closes and the user logs off. And the exception does not occur anywhere.
Actual behavior
An exception occurs
Environment
MahApps.Metro version: v2.4.11
Windows build number: Win11 or Windows build number: Windows Server 2025 Datacenter 24H2 [26100.4652]
Visual Studio: 2022 Version 17.8.4
Target Framework: .Net Framework 4.8
Screenshots
The calling thread cannot access this object because a different thread owns it
at System.Windows.Threading.Dispatcher.VerifyAccess()
at MahApps.Metro.Behaviors.WindowsSettingBehavior.SaveWindowState()
at System.Windows.Application.OnSessionEnding(SessionEndingCancelEventArgs e)
at System.Windows.Application.WmQueryEndSession(IntPtr lParam, IntPtr& refInt)
at System.Windows.Application.AppFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)