Skip to content

[BUG] NullReferenceException pressing Android 'back' button when (IDialogService) Dialog is displayed [MAUI/9.0.271-pre] #3018

@MartinRobins

Description

@MartinRobins

Description

If you display a dialog using IDialogService and then tap the Android back button whilst the dialog is displayed, the application crashes with a NullReferenceException.

Repo:
PrismIssue.zip

Steps to Reproduce

Unzip the attached repo.
Open in Visual Studio 2022 (I am using 17.8.2)
Build and deploy to an Android device that has a back button.
Click the button on the first screen to open the dialog.
Press the Android back button

Platform with bug

.NET MAUI

Affected platforms

Android, I was not able test on other platforms

Did you find any workaround?

The only workaround I have to date is to disable the back button in the MainActivity of the Android application - this works for the specific project I am working on but will be a pain for other up-coming projects.

Relevant log output

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
[mono-rt]    at Prism.Ioc.IContainerProviderExtensions.Resolve[INavigationService](IContainerProvider provider) in /_/src/Prism.Container.Abstractions/IContainerProviderExtensions.cs:line 16
[mono-rt]    at Prism.Navigation.Xaml.Navigation.GetNavigationService(Page page) in D:\a\Prism\Prism\src\Maui\Prism.Maui\Navigation\Xaml\Navigation.cs:line 117
[mono-rt]    at Prism.Navigation.PrismWindow.PrismWindow_ModalPopping(Object sender, ModalPoppingEventArgs e) in D:\a\Prism\Prism\src\Maui\Prism.Maui\Navigation\PrismWindow.cs:line 82
[mono-rt]    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
[mono-rt]    at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
[mono-rt]    at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 36
[mono-rt]    at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:line 84
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 26

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions