{"record":{"id":"6d44cefb7670804a","repo":"unoplatform/uno","slug":"failed-to-load-e-sourcepagetype-fullname-e-exc","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/5.3/uno53AppWithLib/uno53AppWithLib/App.xaml.cs","lineNumber":63,"sourceCode":"            // When the navigation stack isn't restored navigate to the first page,\n            // configuring the new page by passing required information as a navigation\n            // parameter\n            rootFrame.Navigate(typeof(MainPage), args.Arguments);\n        }\n\n        MainWindow.SetWindowIcon();\n        // Ensure the current window is active\n        MainWindow.Activate();\n    }\n\n    /// <summary>\n    /// Invoked when Navigation to a certain page fails\n    /// </summary>\n    /// <param name=\"sender\">The Frame which failed navigation</param>\n    /// <param name=\"e\">Details about the navigation failure</param>\n    void OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n    {\n        throw new InvalidOperationException($\"Failed to load {e.SourcePageType.FullName}: {e.Exception}\");\n    }\n\n    /// <summary>\n    /// Configures global Uno Platform logging\n    /// </summary>\n    public static void InitializeLogging()\n    {\n#if DEBUG\n        // Logging is disabled by default for release builds, as it incurs a significant\n        // initialization cost from Microsoft.Extensions.Logging setup. If startup performance\n        // is a concern for your application, keep this disabled. If you're running on the web or\n        // desktop targets, you can use URL or command line parameters to enable it.\n        //\n        // For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html\n\n        var factory = LoggerFactory.Create(builder =>\n        {\n#if __WASM__","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SolutionTemplate/5.3/uno53AppWithLib/uno53AppWithLib/App.xaml.cs#L45-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before (template default — crashes the app)\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    throw new InvalidOperationException($\"Failed to load {e.SourcePageType.FullName}: {e.Exception}\");\n}\n\n// after (log + show fallback page)\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    _logger.LogError(e.Exception, \"Navigation to {Page} failed\", e.SourcePageType?.FullName);\n    e.Handled = true;\n    (sender as Frame)?.Navigate(typeof(ErrorPage));\n}","handlingStrategy":"try-catch","validationCode":"static bool CanNavigate(Frame f, Type page) => page != null && f.Content?.GetType() != page; // lightweight pre-check; full safety needs try/catch","typeGuard":null,"tryCatchPattern":"try { frame.Navigate(pageType); } catch (InvalidOperationException) { /* template re-throws on nav failure; wrap Navigate */ log.Error($\"Navigation to {pageType} failed\"); frame.Navigate(typeof(ErrorPage)); }","preventionTips":["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."],"tags":["navigation","uno-template","frame","app-lifecycle","boilerplate"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}