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
Describe the bug
DetectTheme is throwing a ANE when there is no app or window. This sounds like a good idea, but there's no way to catch these exceptions as HandleUserPreferenceChanged is private. So it causes the application to crash. This doesn't happen frequently but during closing it shouldn't cause a crash as other stuff might still require a dispose or save.
Environment:
MahApps.Metro version: 2.0.0-alpha0309
OS: W10 Home
Additional context
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: app
at MahApps.Metro.ThemeManager.DetectTheme(System.Windows.Application app) at offset 18 in C:\projects\mahapps-metro\src\MahApps.Metro\ThemeManager\ThemeManager.cs:line 821:col 17
at MahApps.Metro.ThemeManager.ChangeThemeBaseColor(System.Windows.Application app, System.String baseColor) at offset 0 in C:\projects\mahapps-metro\src\MahApps.Metro\ThemeManager\ThemeManager.cs:line 622:col 13
at MahApps.Metro.ThemeManager.HandleUserPreferenceChanged(System.Object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e) at offset 14 in C:\projects\mahapps-metro\src\MahApps.Metro\ThemeManager\ThemeManager.cs:line 978:col 9
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(System.Object target, System.Object[] arguments, System.Signature sig, System.Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object obj, System.Object[] parameters, System.Object[] arguments) at offset 22
at System.Delegate.DynamicInvokeImpl(System.Object[] args) at offset 36
at Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.InvokeCallback(System.Object arg) at offset 18
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, System.Object args, System.Int32 numArgs) at offset 142
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object source, System.Delegate callback, System.Object args, System.Int32 numArgs, System.Delegate catchHandler) at offset 2
The text was updated successfully, but these errors were encountered:
It could be that the current App is null when the system event UserPreferenceChanged occurs
Just check this situation now to prevent the upcoming ArgumentNullException with an additional trace warning in debug mode.
Describe the bug
DetectTheme is throwing a ANE when there is no app or window. This sounds like a good idea, but there's no way to catch these exceptions as HandleUserPreferenceChanged is private. So it causes the application to crash. This doesn't happen frequently but during closing it shouldn't cause a crash as other stuff might still require a dispose or save.
Environment:
2.0.0-alpha0309
Additional context
The text was updated successfully, but these errors were encountered: