{"record":{"id":"d35fb0848038b059","repo":"unoplatform/uno","slug":"failed-to-load-page-e-sourcepagetype-e-excepti","errorCode":null,"errorMessage":"Failed to load Page {e.SourcePageType}: {e.Exception}","messagePattern":"Failed to load Page (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/SamplesApp/SamplesApp.Shared/App.xaml.cs","lineNumber":456,"sourceCode":"\t\t\t{\n\t\t\t\tvar dlg = new MessageDialog(args, \"Launch arguments\");\n\t\t\t\tawait dlg.ShowAsync();\n\t\t\t}\n\n\t\t\tif (SampleControl.Presentation.SampleChooserViewModel.Instance is { } vm && vm.CurrentSelectedSample is null)\n\t\t\t{\n\t\t\t\tvm.SetSelectedSample(CancellationToken.None, \"_None\", \"Playground\");\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Invoked when Navigation to a certain page fails\n\t\t/// </summary>\n\t\t/// <param name=\"sender\">The Frame which failed navigation</param>\n\t\t/// <param name=\"e\">Details about the navigation failure</param>\n\t\tvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n\t\t{\n\t\t\tthrow new Exception($\"Failed to load Page {e.SourcePageType}: {e.Exception}\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Invoked when application execution is being suspended.  Application state is saved\n\t\t/// without knowing whether the application will be terminated or resumed with the contents\n\t\t/// of memory still intact.\n\t\t/// </summary>\n\t\t/// <param name=\"sender\">The source of the suspend request.</param>\n\t\t/// <param name=\"e\">Details about the suspend request.</param>\n\t\tprivate void OnSuspending(object sender, SuspendingEventArgs e)\n\t\t{\n\t\t\t_isSuspended = true;\n\n\t\t\tvar deferral = e.SuspendingOperation.GetDeferral();\n\n\t\t\tConsole.WriteLine($\"OnSuspending (Deadline:{e.SuspendingOperation.Deadline})\");\n\n\t\t\tdeferral.Complete();","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs#L438-L474","documentation":"Thrown by the OnNavigationFailed handler whenever a Frame.Navigate fails to construct/instantiate the target page (type not found, constructor threw, XAML parse error). The handler re-wraps the NavigationFailedEventArgs into a new Exception to fail loudly rather than swallow navigation errors.","triggerScenarios":"Frame.Navigate(typeof(MissingPage)) where the type isn't registered/available; the page's parameterless or parameterized constructor throws; XAML in the target page fails to parse; the page type lives in an assembly not loaded on the current platform.","commonSituations":"Renaming/removing a page without updating Navigate calls; platform-conditional page that is compiled out on the current target; broken XAML or a missing resource key referenced in the page; constructor dependency that is null.","solutions":["Inspect the inner e.Exception in the message — it names the real cause (TypeLoadException, XamlParseException, etc.).","Verify the target page type exists and is constructible on the current platform target.","Fix the page's XAML/constructor error surfaced by the inner exception.","Register the page assembly so the type loader can find it."],"exampleFix":"// before\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    throw new Exception($\"Failed to load Page {e.SourcePageType}: {e.Exception}\");\n}\n// after - preserve the original exception as InnerException for stack traces\nvoid OnNavigationFailed(object sender, NavigationFailedEventArgs e)\n{\n    throw new InvalidOperationException($\"Failed to load Page {e.SourcePageType}.\", e.Exception);\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate the target type is constructible on this platform\nvar pageType = typeof(TargetPage);\nif (pageType is null) throw new InvalidOperationException(\"Target page type not found.\");\nif (pageType.GetConstructor(Type.EmptyTypes) is null) throw new InvalidOperationException($\"{pageType} has no parameterless constructor.\");","typeGuard":null,"tryCatchPattern":"try { rootFrame.Navigate(typeof(TargetPage)); }\ncatch (Exception ex) when (ex.Message.Contains(\"Failed to load Page\"))\n{\n    _log.Error($\"Navigation failed: {ex.Message}\");\n    // fall back to a known page\n}","preventionTips":["Verify target page types exist and are constructible before navigating.","Preserve the original exception as InnerException for diagnostics.","Test navigation paths on every platform target to catch compiled-out pages."],"tags":["navigation","frame","xaml","startup","samples"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}