unoplatform/uno · error · Exception

Failed to load Page {e.SourcePageType}: {e.Exception}

Error message

Failed to load Page {e.SourcePageType}: {e.Exception}

What it means

Thrown by the OnNavigationFailed handler whenever a Frame.Navigate fails to construct/instantiate the target page (type not found, constructor threw, XAML parse error). The handler re-wraps the NavigationFailedEventArgs into a new Exception to fail loudly rather than swallow navigation errors.

Source

Thrown at src/SamplesApp/SamplesApp.Shared/App.xaml.cs:456

			{
				var dlg = new MessageDialog(args, "Launch arguments");
				await dlg.ShowAsync();
			}

			if (SampleControl.Presentation.SampleChooserViewModel.Instance is { } vm && vm.CurrentSelectedSample is null)
			{
				vm.SetSelectedSample(CancellationToken.None, "_None", "Playground");
			}
		}

		/// <summary>
		/// Invoked when Navigation to a certain page fails
		/// </summary>
		/// <param name="sender">The Frame which failed navigation</param>
		/// <param name="e">Details about the navigation failure</param>
		void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
		{
			throw new Exception($"Failed to load Page {e.SourcePageType}: {e.Exception}");
		}

		/// <summary>
		/// Invoked when application execution is being suspended.  Application state is saved
		/// without knowing whether the application will be terminated or resumed with the contents
		/// of memory still intact.
		/// </summary>
		/// <param name="sender">The source of the suspend request.</param>
		/// <param name="e">Details about the suspend request.</param>
		private void OnSuspending(object sender, SuspendingEventArgs e)
		{
			_isSuspended = true;

			var deferral = e.SuspendingOperation.GetDeferral();

			Console.WriteLine($"OnSuspending (Deadline:{e.SuspendingOperation.Deadline})");

			deferral.Complete();

View on GitHub (pinned to 0418340488)

Solutions

  1. Inspect the inner e.Exception in the message — it names the real cause (TypeLoadException, XamlParseException, etc.).
  2. Verify the target page type exists and is constructible on the current platform target.
  3. Fix the page's XAML/constructor error surfaced by the inner exception.
  4. Register the page assembly so the type loader can find it.

Example fix

// before
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
    throw new Exception($"Failed to load Page {e.SourcePageType}: {e.Exception}");
}
// after - preserve the original exception as InnerException for stack traces
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
    throw new InvalidOperationException($"Failed to load Page {e.SourcePageType}.", e.Exception);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate the target type is constructible on this platform
var pageType = typeof(TargetPage);
if (pageType is null) throw new InvalidOperationException("Target page type not found.");
if (pageType.GetConstructor(Type.EmptyTypes) is null) throw new InvalidOperationException($"{pageType} has no parameterless constructor.");

Try / catch

try { rootFrame.Navigate(typeof(TargetPage)); }
catch (Exception ex) when (ex.Message.Contains("Failed to load Page"))
{
    _log.Error($"Navigation failed: {ex.Message}");
    // fall back to a known page
}

Prevention

When it happens

Trigger: Frame.Navigate(typeof(MissingPage)) where the type isn't registered/available; the page's parameterless or parameterized constructor throws; XAML in the target page fails to parse; the page type lives in an assembly not loaded on the current platform.

Common situations: Renaming/removing a page without updating Navigate calls; platform-conditional page that is compiled out on the current target; broken XAML or a missing resource key referenced in the page; constructor dependency that is null.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/d35fb0848038b059. Report an issue: GitHub.