OudomMunint / .NetMAUI-To-Do-List-App

A to do list app that performs CRUD operations. Made with .Net MAUI
36 stars 6 forks source link

Bug - Dark-mode crash #188

Closed OudomMunint closed 1 month ago

OudomMunint commented 1 month ago

Settings > Dark mode switch > Crash System > Dark mode > Crash

Exception:

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Collections.Generic.KeyNotFoundException: The resource 'DarkGH' is not present in the dictionary.
   at Microsoft.Maui.Controls.ResourceDictionary.get_Item(String index)
   at ToDoListApp.Views.TodoListPage.<.ctor>b__1_0(Object s, AppThemeChangedEventArgs a) in /Users/dom/Documents/GitHub Repos/NetMAUI-To-Do-List-App/Views/TodoListPage.xaml.cs:line 28
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Maui.WeakEventManager.HandleEvent(Object sender, Object args, String eventName)
   at Microsoft.Maui.Controls.Application.TriggerThemeChangedActual()
   at Microsoft.Maui.Controls.Application.set_PlatformAppTheme(AppTheme value)
   at Microsoft.Maui.Controls.Application.Microsoft.Maui.IApplication.ThemeChanged()
   at Microsoft.Maui.Platform.PageViewController.TraitCollectionDidChange(UITraitCollection previousTraitCollection)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at ToDoListApp.Program.Main(String[] args) in /Users/dom/Documents/GitHub Repos/NetMAUI-To-Do-List-App/Platforms/iOS/Program.cs:line 13
2024-05-24 23:18:31.943 ToDoListApp[20716:1316826] Unhandled managed exception: Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Maui.WeakEventManager.HandleEvent(Object sender, Object args, String eventName)
   at Microsoft.Maui.Controls.Application.TriggerThemeChangedActual()
   at Microsoft.Maui.Controls.Application.set_PlatformAppTheme(AppTheme value)
   at Microsoft.Maui.Controls.Application.Microsoft.Maui.IApplication.ThemeChanged()
   at Microsoft.Maui.Platform.PageViewController.TraitCollectionDidChange(UITraitCollection previousTraitCollection)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at ToDoListApp.Program.Main(String[] args) in /Users/dom/Documents/GitHub Repos/NetMAUI-To-Do-List-App/Platforms/iOS/Program.cs:line 13
The resource 'DarkGH' is not present in the dictionary. (System.Collections.Generic.KeyNotFoundException)
   at Microsoft.Maui.Controls.ResourceDictionary.get_Item(String index)
   at ToDoListApp.Views.TodoListPage.<.ctor>b__1_0(Object s, AppThemeChangedEventArgs a) in /Users/dom/Documents/GitHub Repos/NetMAUI-To-Do-List-App/Views/TodoListPage.xaml.cs:line 28
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
OudomMunint commented 1 month ago

Fixed by PR #189