unoplatform/uno · error · InvalidOperationException

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

Error message

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

What it means

Default OnNavigationFailed handler in the UnoAppWinUILinuxValidation solution template (App.cs). Same contract as other Uno WinUI templates: the Frame raises NavigationFailed on a page load failure, and the handler wraps the inner exception into InvalidOperationException and re-throws, terminating the app. This template is specifically used for Linux/Skia validation, so failures often relate to that target.

Source

Thrown at src/SolutionTemplate/UnoAppWinUILinuxValidation/UnoAppWinUILinuxValidation/App.cs:95

			{
				// When the navigation stack isn't restored navigate to the first page,
				// configuring the new page by passing required information as a navigation
				// parameter
				rootFrame.Navigate(typeof(MainPage), args.Arguments);
			}
			// Ensure the current window is active
			MainWindow.Activate();
		}
	}

	/// <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 InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {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)
	{
		var deferral = e.SuspendingOperation.GetDeferral();
		//TODO: Save the application state and stop any background activity
		deferral.Complete();
	}
}

View on GitHub (pinned to 0418340488)

Solutions

  1. Inspect e.Exception for the underlying cause; the wrapper only identifies the page.
  2. Run on the Linux/Skia validation target to reproduce and capture the first-chance exception.
  3. Check the page for Windows-only APIs without platform guards and verify resources resolve on Skia.
  4. Swap the throw for logging + e.Handled=true + fallback page for non-crashing production behavior.

Example fix

// before
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
    throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
}

// after
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
    _logger.LogError(e.Exception, "Nav failed (Linux): {Page}", e.SourcePageType?.FullName);
    e.Handled = true;
}
Defensive patterns

Strategy: try-catch

Validate before calling

static bool CanNavigate(Frame f, Type page) => page != null && f.Content?.GetType() != page;

Try / catch

try { frame.Navigate(pageType); } catch (InvalidOperationException) { log.Error($"Linux nav failed: {pageType}"); frame.Navigate(typeof(ErrorPage)); }

Prevention

When it happens

Trigger: Frame.Navigate to a page that throws during construction or XAML load, particularly on the Linux/Skia validation target where platform surface differs.

Common situations: Page constructor throws because a Linux-incompatible API is called, a resource fails to resolve on Skia, x:Class mismatch, or a platform guard excluding the page on Linux.

Related errors


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