-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Getting exception while navigating in Release mode on iOS #3097
Comments
All bug reports require a reproduction app |
TestNav.zip |
Hi what is the status of this issue? I think I'm having the same issue on my end. |
Unable to reproduce and you do not have any exception details here. Note about your reproduction:
|
Okay Thanks! |
Here's the thing though, do you know why this works in debug, but then has this issue in realease mode? |
I never was able to reproduce it and you haven't actually given me an error that you're hitting so anything I could tell you would be purely a guess. That said there should be nothing Prism specific that would cause this. |
@dansiegel (I am not the same guy, lol) This may not be relevant to this post, and I do apologize for bothering you, but the reason why my code was not working in my case in release mode was because of the fact that when I included value converters, the maui UI toolkit (xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit") along with some other custom controls from an xmlns namespace definitions. it breaks. However, when I remove all of these things from the XAML document, it runs just fine, although with missing functionality. I also have a custom base nav page extending from the prism navigation page: internal class BaseNavigationPage : PrismNavigationPage
{
#if ANDROID
INavigationPageController NavigationPageController => this;
public new event EventHandler BackButtonPressed;
public BaseNavigationPage()
{
BarTextColor = Colors.White;
BarBackgroundColor = Color.FromArgb("#4085c0");
BackButtonPressed += HandleBackButtonPressed;
}
public BaseNavigationPage(Page page) : base(page)
{
BarTextColor = Colors.White;
BarBackgroundColor = Color.FromArgb("#4085c0");
BackButtonPressed += HandleBackButtonPressed;
}
private async void HandleBackButtonPressed(object sender, EventArgs args)
{
await MvvmHelpers.HandleNavigationPageGoBack(this);
}
#else
public BaseNavigationPage()
{
BarTextColor = Colors.White;
BarBackgroundColor = Color.FromArgb("#4085c0");
}
public BaseNavigationPage(Page page)
: base(page)
{
BarTextColor = Colors.White;
BarBackgroundColor = Color.FromArgb("#4085c0");
}
#endif
protected override bool OnBackButtonPressed()
{
#if ANDROID
if (CurrentPage.SendBackButtonPressed())
return true;
if (NavigationPageController.StackDepth > 1)
{
BackButtonPressed.Invoke(this, EventArgs.Empty);
return true;
}
return false;
#else
return base.OnBackButtonPressed();
#endif
}
} As for the Error:
And my code for the prism startup method in the maui program file: public static void Configure(PrismAppBuilder builder)
{
builder.RegisterTypes(RegisterTypes).CreateWindow(navigationService =>
{
var builder = navigationService.CreateBuilder();
builder.AddSegment("LoginPage");
var nav = builder.NavigateAsync();
nav.OnNavigationError(err =>
{
var message = err;
});
return nav;
});
} As for more details, I will gladly give them to you with a test project if you wish in a zip file. |
I apologize for the poor formatting. |
@Baraiboapex I realize you're not the original reporter of the issue... however neither of you have actually provided an error that points to something actionable as an issue with Prism. The exception:
Tells us that the problem is in your code that there was an exception thrown by the constructor of the Page that was being navigated to. If you look closer you'll realize that's a NavigationException that probably has a ContainerResolutionException as it's InnerException... and if you inspect that ContainerResolutionException and call I'm also not sure why you're inheriting from PrismNavigationPage and then trying to duplicate it's logic that is going to cause you a lot of problems... There isn't anything you have there that even suggests a need for you to have a base NavigationPage in your codebase at all. The colors can be done easily with implicit styles from your app. |
Ah! That's right! I apologize I forgot about the get errors exception! Thanks for your help! I will get back to you with this information here in a little while (probably tomorrow) and will address your other points as well. I can tell you this however about the duplicate logic for the navigation page. This was added to address the problem of the prism navigation page closing suddenly after the back button is pressed on the android platform. It was provided as a work around by another person who was commenting on the related issue's thread. Here is the original link here: https://github.com/PrismLibrary/Prism/issues/2990#issuecomment-2027892817. Do let me know if this was corrected in a new version and if I just need to update my version, because I do think that I asked when it was going to be released. |
I also just wanted to say thank you for being so prompt with your replies. And I hope that we can eventually help the original user understand what's going on. |
Update. @dansiegel This appears to be an issue with iOS as the error that I got after wading through all of the exceptions returned from the navigation exception catcher, the innermost exception says "RootViewController cannot be null." This appears to be quite a notorious issue in .NET MAUI. Based off of my current research. Let me know if you have any suggestions on how to fix this. I will get back with you tomorrow on this. Have a good one. |
Description
I'm having a strange issue with .net MAUI, when I run app in release mode on iOS navigation is not working, I'm getting below exception.
When i'm clicking first time on button for Navigation i'm getting below exception,
Prism.Navigation.NavigationException: An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization exception
second time when I'm clicking same button I'm getting different exception,
Prism.Navigation.NavigationException: An unsupported event occurred while Navigating. The attempted Navigation Stack is not supported by .NET MAUI
App is working fine in debug mode on both Android and iOS, but in release mode it is only working on Android.
Steps to Reproduce
Create new blank MAUI app
Add Prism.DryIoc.Maui 9.0.271-pre
Add a button on ViewA to Navigate to ViewB
Add command on ViewModelA for navigation
private async Task DoGoToViewB()
{
_navigationService.NavigateAsync("ViewB")
.OnNavigationError(ex => Console.WriteLine("\nDoGoToViewB-------- " + ex)); ;
}
register View and ViewModels in MauiProgram
private static void RegisterNavigationDependency(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation();
containerRegistry.RegisterForNavigation<ViewA, ViewModelA>();
containerRegistry.RegisterForNavigation<ViewB, ViewModelB>();
}
set onAppStart:
.UseMauiApp().
UsePrism(prism =>
{
prism.RegisterTypes(RegisterNavigationDependency);
prism.OnAppStart("ViewA");
Platform with bug
.NET MAUI
Affected platforms
iOS
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: