You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following exception is thrown in ShowMessageAsync() after update from MahApps.Metro V1.3.0 to V1.4.2:
System.InvalidOperationException wurde nicht von Benutzercode behandelt.
HResult=-2146233079
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace:
at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.Application.get_MainWindow()
at MahApps.Metro.Controls.Dialogs.BaseMetroDialog.DetectTheme(DependencyObject dialog) in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\BaseMetroDialog.cs:line 229
at MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme() in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\BaseMetroDialog.cs:line 155
at MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize(MetroWindow owningWindow, MetroDialogSettings settings) in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\BaseMetroDialog.cs:line 135
at MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor(MetroWindow owningWindow, MetroDialogSettings settings) in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\BaseMetroDialog.cs:line 93
at MahApps.Metro.Controls.Dialogs.MessageDialog..ctor(MetroWindow parentWindow, MetroDialogSettings settings) in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\MessageDialog.cs:line 27
at MahApps.Metro.Controls.Dialogs.DialogManager.<>c__DisplayClass2_0.<ShowMessageAsync>b__1() in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\Dialogs\DialogManager.cs:line 164
at System.Windows.Threading.DispatcherOperation`1.InvokeDelegateCore()
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
The ShowMessageAsync() has to be shown in a sub MetroWindow. The sub window is running within his own thread and Dispatcher context:
Thread thread = new Thread(() =>
{
SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher)); // create and install a context
WindowBase dialog = (WindowBase)dllAssembly.CreateInstance(dialogClass);
dialog.Show();
Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = false;
thread.Start();
So the access to the applications main window (System.Windows.Application.get_MainWindow()) is problematic. My code is working with V1.3.0 of MahApps flawless.
Expected outcome
Same behaviour like in previous major version 1.3.0 => no exception
--
Environment
MahApps.Metro v1.4.2
Windows 7
Visual Studio 2013
.NET Framework 4.6.2
--
Thank you!!!
Thank you very much for your amazing and absolutely impressiv GUI framework, which is gives the right touch to the standard WPF GUI._
The text was updated successfully, but these errors were encountered:
What steps will reproduce this issue?
Following exception is thrown in ShowMessageAsync() after update from MahApps.Metro V1.3.0 to V1.4.2:
The ShowMessageAsync() has to be shown in a sub MetroWindow. The sub window is running within his own thread and Dispatcher context:
So the access to the applications main window (System.Windows.Application.get_MainWindow()) is problematic. My code is working with V1.3.0 of MahApps flawless.
Expected outcome
Same behaviour like in previous major version 1.3.0 => no exception
--
Environment
--
Thank you!!!
Thank you very much for your amazing and absolutely impressiv GUI framework, which is gives the right touch to the standard WPF GUI._
The text was updated successfully, but these errors were encountered: