MAUI App navigation and messaging not working since update to .NET 8

Leonardo D’Incau 0 Reputation points
2024-09-24T14:37:03.2633333+00:00

I am having this error 'No destination with ID 10 is on the NavController's back stack. The current destination is Destination(0x5) class=crc6452ffdc5b34af3a0f.NavigationViewFragment' since I updated my app from .net7 to .net 8 due to the urge of Google Play store to set Android Framework target to 14. In particular, it happens every time i try to perform a pop in my app, even if the NavigationStack is not empty. In fact, the page is correctly popped (at least visually) but this exception in thrown and it prevents the app from functioning properly (I use wekreferencemessenger to send a message from the page that is popped to the previous one and after updating to .net8 and getting this error the message is no longer received). All of this works perfectly in .NET7 and even if doing a manual downgrade again from the broken .NET8 one to .NET 7
Please give a solution because this error is preventing us from updating the app on the store before the limit imposed by Google.

i think that the above error about navcontroller prevents the correct behavior of it)

On the page that will be popped:

Message message = new Message()
{
    Item = selectedItem
};
WeakReferenceMessenger.Default.Send(message);

//pops page inside the detail of my flouytpage
await ((NavigationPage)((FlyoutPage)App.Current.MainPage).Detail).PopAsync(true);

On the page that is reached after the pop:

public void Receive(Message message)
{
	//assign the message content to the actual page variable (binded to the xaml)
    this.ReceivedItem = message.Item;

	//...other operations of my app using the messsage data
    //...
}
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,453 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.