{"record":{"id":"b2ffdd5a85272d41","repo":"unoplatform/uno","slug":"failed-to-load-e-sourcepagetype-fullname-e-exc-b2ffdd","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/UnoAppWinUI/UnoAppWinUI/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/UnoAppWinUI/UnoAppWinUI/App.cs#L77-L112","documentation":"Default OnNavigationFailed handler in the UnoAppWinUI solution template (App.cs). When the Frame cannot load the requested SourcePageType, the handler wraps the inner exception in InvalidOperationException and re-throws, crashing the app. Standard Uno/WinUI fail-fast template behavior for surfacing navigation problems in development.","triggerScenarios":"Frame.Navigate to a page type that cannot be activated, or whose constructor/XAML initialization throws on the running WinUI target.","commonSituations":"Page not in the project, x:Class mismatch, constructor throws (null DI dependency, unresolved resource), or a platform guard excluding the page.","solutions":["Look at e.Exception for the real cause; the message's page name is just context.","Confirm the page type exists, compiles, and that x:Class matches namespace.type.","Debug the page constructor and OnNavigatedTo to capture the original exception first-chance.","Replace the throw with logging + e.Handled=true + a fallback page for production tolerance."],"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: {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($\"WinUI nav failed: {pageType}\"); frame.Navigate(typeof(ErrorPage)); }","preventionTips":["Replace the template throw with logging + e.Handled=true.","Verify x:Class and project inclusion for each page.","Unit-test page construction before wiring navigation."],"tags":["navigation","uno-template","frame","winui","boilerplate"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}