{"record":{"id":"d00fbc46413c49a3","repo":"unoplatform/uno","slug":"failed-to-load-e-sourcepagetype-fullname-e-exc-d00fbc","errorCode":null,"errorMessage":"Failed to load {e.SourcePageType.FullName}: {e.Exception}","messagePattern":"Failed to load (.+?): (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SolutionTemplate/UnoAppWinUILinuxValidation/UnoAppWinUILinuxValidation/App.cs","lineNumber":95,"sourceCode":"\t\t\t{\n\t\t\t\t// When the navigation stack isn't restored navigate to the first page,\n\t\t\t\t// configuring the new page by passing required information as a navigation\n\t\t\t\t// parameter\n\t\t\t\trootFrame.Navigate(typeof(MainPage), args.Arguments);\n\t\t\t}\n\t\t\t// Ensure the current window is active\n\t\t\tMainWindow.Activate();\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Invoked when Navigation to a certain page fails\n\t/// </summary>\n\t/// <param name=\"sender\">The Frame which failed navigation</param>\n\t/// <param name=\"e\">Details about the navigation failure</param>\n\tvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n\t{\n\t\tthrow new InvalidOperationException($\"Failed to load {e.SourcePageType.FullName}: {e.Exception}\");\n\t}\n\n\t/// <summary>\n\t/// Invoked when application execution is being suspended.  Application state is saved\n\t/// without knowing whether the application will be terminated or resumed with the contents\n\t/// of memory still intact.\n\t/// </summary>\n\t/// <param name=\"sender\">The source of the suspend request.</param>\n\t/// <param name=\"e\">Details about the suspend request.</param>\n\tprivate void OnSuspending(object sender, SuspendingEventArgs e)\n\t{\n\t\tvar deferral = e.SuspendingOperation.GetDeferral();\n\t\t//TODO: Save the application state and stop any background activity\n\t\tdeferral.Complete();\n\t}\n}\n","sourceCodeStart":77,"sourceCodeEnd":112,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SolutionTemplate/UnoAppWinUILinuxValidation/UnoAppWinUILinuxValidation/App.cs#L77-L112","documentation":"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.","triggerScenarios":"Frame.Navigate to a page that throws during construction or XAML load, particularly on the Linux/Skia validation target where platform surface differs.","commonSituations":"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.","solutions":["Inspect e.Exception for the underlying cause; the wrapper only identifies the page.","Run on the Linux/Skia validation target to reproduce and capture the first-chance exception.","Check the page for Windows-only APIs without platform guards and verify resources resolve on Skia.","Swap the throw for logging + e.Handled=true + fallback page for non-crashing production behavior."],"exampleFix":"// before\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    throw new InvalidOperationException($\"Failed to load {e.SourcePageType.FullName}: {e.Exception}\");\n}\n\n// after\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    _logger.LogError(e.Exception, \"Nav failed (Linux): {Page}\", e.SourcePageType?.FullName);\n    e.Handled = true;\n}","handlingStrategy":"try-catch","validationCode":"static bool CanNavigate(Frame f, Type page) => page != null && f.Content?.GetType() != page;","typeGuard":null,"tryCatchPattern":"try { frame.Navigate(pageType); } catch (InvalidOperationException) { log.Error($\"Linux nav failed: {pageType}\"); frame.Navigate(typeof(ErrorPage)); }","preventionTips":["Run navigation on the Linux/Skia validation target to reproduce first-chance exceptions.","Guard Windows-only APIs in pages with OperatingSystem.IsWindowsVersionAtLeast checks.","Replace the throw with graceful handling for production tolerance."],"tags":["navigation","uno-template","frame","linux","skia","boilerplate"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}