dotnet/maui · error · InvalidOperationException

Cannot navigate to FormsEmbeddedPageWrapper without providin

Error message

Cannot navigate to FormsEmbeddedPageWrapper without providing a Page identifier.

What it means

Thrown as InvalidOperationException by FormsEmbeddedPageWrapper.OnNavigatedTo when the navigation parameter (e.Parameter) is null. FormsEmbeddedPageWrapper expects a Guid identifier that maps to a ContentPage in its internal Pages dictionary; navigating without a parameter means there is no page to display.

Source

Thrown at src/Compatibility/Core/src/Windows/PageExtensions.cs:24

namespace Microsoft.Maui.Controls.Compatibility.Platform.UWP
{
	public sealed partial class FormsEmbeddedPageWrapper : Microsoft.UI.Xaml.Controls.Page
	{
		internal static Dictionary<Guid, ContentPage> Pages = new Dictionary<Guid, ContentPage>();

		public FormsEmbeddedPageWrapper()
		{
			InitializeComponent();
		}

		protected override void OnNavigatedTo(Microsoft.UI.Xaml.Navigation.NavigationEventArgs e)
		{
			base.OnNavigatedTo(e);

			if (e.Parameter == null)
			{
				throw new InvalidOperationException($"Cannot navigate to {nameof(FormsEmbeddedPageWrapper)} without "
					+ $"providing a {nameof(Microsoft.Maui.Controls.Page)} identifier.");
			}

			// Find the page instance in the dictionary and then discard it so we don't prevent it from being collected
			var key = (Guid)e.Parameter;
			var page = Pages[key];
			Pages.Remove(key);

			// Convert that page into a FrameWorkElement we can display in the ContentPresenter
			FrameworkElement frameworkElement = page.CreateFrameworkElement();

			if (frameworkElement == null)
			{
				throw new InvalidOperationException($"Could not find or create a renderer for the Page {page}");
			}

			Root.Content = frameworkElement;
		}

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Always pass a Guid when navigating: Frame.Navigate(typeof(FormsEmbeddedPageWrapper), guid).
  2. Register the ContentPage in FormsEmbeddedPageWrapper.Pages[guid] = page before navigating with that guid.
  3. Ensure no middleware or navigation interceptors strip the parameter.

Example fix

// before
Frame.Navigate(typeof(FormsEmbeddedPageWrapper));

// after
var guid = Guid.NewGuid();
FormsEmbeddedPageWrapper.Pages[guid] = contentPage;
Frame.Navigate(typeof(FormsEmbeddedPageWrapper), guid);
Defensive patterns

Strategy: validation

Validate before calling

if (e.Parameter != null && e.Parameter is Guid)
    // safe to proceed with navigation
else
    // navigate away or show error

Prevention

When it happens

Trigger: Navigating to FormsEmbeddedPageWrapper via Frame.Navigate(typeof(FormsEmbeddedPageWrapper)) without passing a Guid parameter, or when the navigation event args have a null Parameter.

Common situations: Calling Frame.Navigate without the second argument; a navigation redirect that strips parameters; or using a navigation template that doesn't forward the Guid.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/572c16078b237332. Report an issue: GitHub.