GithubHelp home page GithubHelp logo

Comments (19)

dansiegel avatar dansiegel commented on June 11, 2024

All bug reports require a reproduction app

from prism.

Himanshu045 avatar Himanshu045 commented on June 11, 2024

TestNav.zip
@dansiegel Please find reproduction app

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

Hi what is the status of this issue? I think I'm having the same issue on my end.

from prism.

dansiegel avatar dansiegel commented on June 11, 2024

Unable to reproduce and you do not have any exception details here. Note about your reproduction:

  1. "\ViewB" should be "/ViewB"
  2. Do not register NavigationPage. In Prism.Maui we have introduced the PrismNavigationPage. Both the NavigationPage and TabbedPage are registered for you automatically. If you require a custom NavigationPage for some reason be sure to use the PrismNavigationPage as the base type.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

Okay Thanks!

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

Okay Thanks!

@dansiegel

Here's the thing though, do you know why this works in debug, but then has this issue in realease mode?

from prism.

dansiegel avatar dansiegel commented on June 11, 2024

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.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

@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:

An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization exception

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.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

I apologize for the poor formatting.

from prism.

dansiegel avatar dansiegel commented on June 11, 2024

@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:

An error occurred while resolving the page. This is most likely the result of invalid XAML or other type initialization 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 ex.GetErrors() then it should help you figure out where the error is coming from. If you aren't injecting anything then the problem would happen even if you did new YourPage() which means it's not a Prism problem.

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.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

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.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

@dansiegel

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.

from prism.

Baraiboapex avatar Baraiboapex commented on June 11, 2024

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.

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.