{"record":{"id":"332433d59bc21d61","repo":"PrismLibrary/Prism","slug":"the-view-type-view-fullname-is-not-a-type-of-page","errorCode":null,"errorMessage":"The view type '{view.FullName}' is not a type of Page.","messagePattern":"The view type '(.+?)' is not a type of Page\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs","lineNumber":28,"sourceCode":"{\n#if !UNO_WINUI\n    private static readonly Type PageType = typeof(Page);\n\n    public static IServiceCollection RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IServiceCollection services, string name = null)\n            where TView : Page =>\n            services.RegisterForNavigation(typeof(TView), null, name);\n\n    public static IServiceCollection RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IServiceCollection services, string name = null)\n        where TView : Page =>\n        services.RegisterForNavigation(typeof(TView), typeof(TViewModel), name);\n\n    public static IServiceCollection RegisterForNavigation(this IServiceCollection services, Type view, Type viewModel, string name = null)\n    {\n        if (view is null)\n            throw new ArgumentNullException(nameof(view));\n\n        if (!view.IsAssignableTo(PageType))\n            throw new InvalidOperationException($\"The view type '{view.FullName}' is not a type of Page.\");\n\n        if (string.IsNullOrEmpty(name))\n            name = view.Name;\n\n        services.AddSingleton(new ViewRegistration\n            {\n                Type = ViewType.Page,\n                Name = name,\n                View = view,\n                ViewModel = viewModel\n            })\n            .AddTransient(view);\n\n        if (viewModel != null)\n            services.AddTransient(viewModel);\n\n        return services;\n    }","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Ioc/MicrosoftDependencyInjectionExtensions.cs#L10-L46","documentation":"RegisterForNavigation validates that the supplied view Type derives from Microsoft.Maui.Controls.Page and throws InvalidOperationException if it does not. Prism navigation is page-based; registering a non-Page type (a ContentView, a plain class, or a ViewModel) cannot be navigated to, so Prism rejects the registration up front.","triggerScenarios":"Calling services.RegisterForNavigation(typeof(SomeContentViewOrViewModel), ...) with a Type not assignable to Page; using Prism.Forms-style ContentView registrations ported to MAUI.","commonSituations":"Migrating from Xamarin.Forms/Prism.Forms to .NET MAUI where 'views' were ContentViews; accidentally registering a ViewModel instead of the View; a same-named non-Page class from another namespace being resolved.","solutions":["Ensure the registered type inherits from Microsoft.Maui.Controls.Page (ContentPage, NavigationPage, etc.)","Register the Page class, not its ViewModel or a ContentView","Check for namespace collisions where a same-named non-Page type is picked up"],"exampleFix":"// before\nservices.RegisterForNavigation(typeof(MainView), typeof(MainViewModel)); // MainView : ContentView\n// after\npublic partial class MainView : ContentPage { ... }\nservices.RegisterForNavigation<MainView, MainViewModel>();","handlingStrategy":"validation","validationCode":"if (viewType is null || !typeof(Page).IsAssignableFrom(viewType))\n    throw new InvalidOperationException($\"{viewType?.FullName} must derive from Microsoft.Maui.Controls.Page\");\nservices.RegisterForNavigation(viewType, viewModelType);","typeGuard":"bool IsPage(Type t) => t is not null && typeof(Page).IsAssignableFrom(t);","tryCatchPattern":"try\n{\n    services.RegisterForNavigation(viewType, viewModelType);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not a type of Page\"))\n{\n    logger.LogError(ex, \"{Type} is not a Page; fix registration\", viewType.FullName);\n    throw;\n}","preventionTips":["Keep all registered views inheriting from ContentPage/Page","Do not reuse Prism.Forms ContentView-registration patterns in MAUI","Watch for duplicate class names across namespaces when resolving types by name"],"tags":["type-mismatch","navigation","maui","di-registration"],"backgroundTag":"type-mismatch","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}