The49.Maui.BottomSheet
The49.Maui.BottomSheet copied to clipboard
[iOS] NullReferenceException when navigating
If a bottomsheet is shown at some point, then when navigating away from that page a nullreferenceexception is thrown.
The strange thing is the error doesn't happen until the user navigates to a different page, so it feels like the clean up is going wrong. I can open and close the bottomsheet repeatedly without problem, but then when I navigate the app crashes.
If I don't open the bottomsheet then I can navigate away without problem.
I can't find a workaround for this either. The only code of mine which is in play at the time is the navigation request, which has a try catch around it, but it doesn't catch this.
At the bottom of the call stack is my call to HideOrgBottomSheet - this is not called as part of the navigate - it is actually called to dismiss the bottom sheet earlier so I don't understand why that code is still running.
Error below.
Error Type: System.NullReferenceException Error Message: Arg_NullReferenceException Stack Trace: at The49.Maui.BottomSheet.BottomSheet.NotifyDismissed() at UIKit.UIViewController.DismissViewController(Boolean , Action ) at The49.Maui.BottomSheet.BottomSheetHandler.Dismiss(BottomSheet view, Object request) at The49.Maui.BottomSheet.BottomSheetHandler.MapDismiss(BottomSheetHandler handler, BottomSheet view, Object request) at Microsoft.Maui.CommandMapper`2.<>c__DisplayClass6_0[[The49.Maui.BottomSheet.BottomSheet, The49.Maui.BottomSheet, Version=8.0.3.0, Culture=neutral, PublicKeyToken=null],[The49.Maui.BottomSheet.BottomSheetHandler, The49.Maui.BottomSheet, Version=8.0.3.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v, Object o) at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args) at Microsoft.Maui.Handlers.ElementHandler.Invoke(String command, Object args) at The49.Maui.BottomSheet.BottomSheet.DismissAsync(Boolean animated) at PDS.App.RedSix.Controls.RedSixMasterPage.HideOrgSelectBottomSheet()