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 Uno 5.6 solution template (uno56netcurrent, integration-test app). Behaves like all Uno templates: when Frame navigation to SourcePageType fails, it wraps the inner exception in InvalidOperationException and re-throws, crashing the app. This template intentionally enables logging for all configurations to surface binding errors.
Source
Thrown at src/SolutionTemplate/5.6/uno56netcurrent/uno56netcurrent/App.xaml.cs:70
MainWindow.SetWindowIcon();
// Ensure the current window is active
MainWindow.Activate();
if (exitAfterLaunching)
{
await Task.Delay(1000);
Exit();
}
}
/// <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()
{
// Logging must be enabled for all build configurations so that `.AddFakeLogging()` can be used to
// catch binding errors in test and production builds.
//
// Performance is not a concern here. This is an integration test.
var factory = LoggerFactory.Create(builder =>
{
#if __WASM__
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
#elif __IOS__
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());View on GitHub (pinned to 0418340488)
Solutions
- Read e.Exception for the true root cause — the wrapped message is only identifying the page.
- Use the enabled logging/FakeLogging output in this template to spot binding errors that precede the crash.
- Confirm x:Class and project inclusion of the page type for the net-current target.
- Replace the throw with diagnostics + e.Handled=true + fallback page for non-crashing 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: {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($"Integration-test nav failed: {pageType}"); frame.Navigate(typeof(ErrorPage)); } Prevention
- Use the template's FakeLogging output to catch binding errors that precede the crash.
- Assert page DI registrations in the integration host at startup.
- Replace the throw with graceful handling for non-crashing tests.
When it happens
Trigger: Frame.Navigate to a page that throws during construction/XAML load, or to a type that cannot be activated in the net-current integration-test host.
Common situations: Page constructor throws (missing DI registration, null dependency), x:Class mismatch, resource/binding error caught by FakeLogging, or a platform guard excluding the page.
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/a42f636212b8d1dc.
Report an issue: GitHub.