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 shipped in the Uno 5.3 solution template (uno53AppWithLib). The Frame raises NavigationFailed when it cannot instantiate or navigate to the requested SourcePageType; the template re-throws the inner exception wrapped with the page name as an InvalidOperationException, crashing the app. This is intentional fail-fast behavior so navigation problems surface immediately during development.
Source
Thrown at src/SolutionTemplate/5.3/uno53AppWithLib/uno53AppWithLib/App.xaml.cs:63
// 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);
}
MainWindow.SetWindowIcon();
// 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>
/// Configures global Uno Platform logging
/// </summary>
public static void InitializeLogging()
{
#if DEBUG
// Logging is disabled by default for release builds, as it incurs a significant
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
// is a concern for your application, keep this disabled. If you're running on the web or
// desktop targets, you can use URL or command line parameters to enable it.
//
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html
var factory = LoggerFactory.Create(builder =>
{
#if __WASM__View on GitHub (pinned to 0418340488)
Solutions
- Open the inner e.Exception to find the true root cause — the wrapper only adds the page name; the real error is inside.
- Verify the target page type is in the same assembly and its x:Class matches the namespace.type exactly.
- Step through the page's constructor / OnNavigatedTo to find what throws; check for null dependencies or unresolved resources.
- For production resilience, replace the throw with logging + a fallback page rather than crashing (see defense strategy).
Example fix
// before (template default — crashes the app)
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
}
// after (log + show fallback page)
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
_logger.LogError(e.Exception, "Navigation to {Page} failed", e.SourcePageType?.FullName);
e.Handled = true;
(sender as Frame)?.Navigate(typeof(ErrorPage));
} Defensive patterns
Strategy: try-catch
Validate before calling
static bool CanNavigate(Frame f, Type page) => page != null && f.Content?.GetType() != page; // lightweight pre-check; full safety needs try/catch
Try / catch
try { frame.Navigate(pageType); } catch (InvalidOperationException) { /* template re-throws on nav failure; wrap Navigate */ log.Error($"Navigation to {pageType} failed"); frame.Navigate(typeof(ErrorPage)); } Prevention
- Replace the template's re-throw with logging + e.Handled=true + fallback page for production.
- Unit-test page construction in isolation before wiring navigation.
- Verify x:Class and project inclusion of every navigable page.
- Inject and assert page dependencies in the DI container at startup.
When it happens
Trigger: Frame.Navigate(typeof(SomePage)) where SomePage's type is registered but its XAML/code-behind throws during construction, or the page type cannot be found/instantiated on the current platform.
Common situations: Page missing from the project, a x:Class mismatch, a constructor that throws (null reference, missing service/dependency), platform-conditional code that fails on a target, or navigation to a page whose XAML resource cannot resolve.
Related errors
- Failed to load {e.SourcePageType.FullName}: {e.Exception}
- Failed to load {e.SourcePageType.FullName}: {e.Exception}
- Failed to load {e.SourcePageType.FullName}: {e.Exception}
- Failed to load {e.SourcePageType.FullName}: {e.Exception}
- Failed to load {e.SourcePageType.FullName}: {e.Exception}
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/6d44cefb7670804a.
Report an issue: GitHub.