The type Prism not found in MAUI (prism.form dll not found in MAUI)

Debasis Patra 0 Reputation points
2024-05-01T15:07:58.3333333+00:00
public partial class App

{

    private static readonly string StartPage = DebugAppConfig.StartupPage;

    public App(IPlatformInitializer initializer = null) : base(initializer)

    {

    }

    private Maybe<Uri> LaunchUri { get; set; } = Maybe<Uri>.None;

    public static AppBuilder Builder()

    {

        return AppBuilder.GetBuilder();

    }

    public async Task HandleLaunchUriAsync(Uri uri)

    {

        await NavigationService.NavigateAsync(

            $"{nameof(NavigationPage)}/{StartPage}",

            new NavigationParameters

                {

                    { NavigationParameterKeys.StartupUri, uri }

                });

    }

    protected override void OnInitialized()

    {

        InitializeComponent();

        Container.Resolve<IDbContext>().Initialize();

        Container.Resolve<IPushHandlerService>().Initialize();

        Container.Resolve<IAppStoreService>().AppInForeground(true);

    }

    protected override async void OnStart()

    {

        base.OnStart();

        ServicePointConfiguration.SetUp();

#if DEBUG

        AppCenter.LogLevel = LogLevel.Verbose;

#endif

        var appName = Container.Resolve<IAppInfoService>().AppInfo.Name;

        string androidKey = null, iosKey = null;

        switch (appName)

        {

            case "mdu":

                androidKey = AppConfig.MduAndroidKey;

                iosKey = AppConfig.MduIosKey;

                break;

            case "ddu":

                androidKey = AppConfig.DduAndroidKey;

                iosKey = AppConfig.DduIosKey;

                break;

        }

        var types = new List<Type>();

#if !DEBUG

        types.Add(typeof(Analytics));

        types.Add(typeof(Crashes));

#endif

        AppCenter.Start(

            $"android={androidKey};" +

            $"ios={iosKey};",

            types.ToArray()

        );

#if !DEBUG

        var jailbrokenOrRooted = Container.Resolve<IJailbrokenOrRootedDetector>().IsJailbrokenOrRooted();

        if (jailbrokenOrRooted)

            await NavigationService.NavigateAsync($"{nameof(NavigationPage)}/{PageNames.JailbreakOrRootDetected}");

        else

#endif

        {

#if !DEBUG

            if (Container.Resolve<ICurrentUser>() != null && string.IsNullOrEmpty(Container.Resolve<IRestSettings>().MembershipNumber))

                await Container.Resolve<IUserService>().SignOutAsync();

#endif

            await NavigateToMainPage();

        }

    }

    protected override void OnSleep()

    {

        base.OnSleep();

        if (Container.Resolve<IXFService>().IsAndroid)

            Container.Resolve<IPushHandlerService>().DeInitialize();

        Container.Resolve<IAppStoreService>().AppInForeground(false);

    }

    protected override void OnResume()

    {

        base.OnResume();

        var xfService = Container.Resolve<IXFService>();

        if (xfService.IsAndroid)

            Container.Resolve<IPushHandlerService>().Initialize();

        Container.Resolve<IAppStoreService>().AppInForeground(true);

        xfService.SendMessage(this, MessageHelpers.AppResumesMessage);

    }

    protected override void RegisterTypes(IContainerRegistry containerRegistry)

    {

        ContainerBootstrap.Setup(containerRegistry);

        var mduMobileApi = Container.Resolve<IMduMobileApiFactory>().Create();

        containerRegistry.RegisterInstance(mduMobileApi);

    }

    private async Task NavigateToMainPage()

    {

        if (LaunchUri.HasValue)

        {

            await HandleLaunchUriAsync(LaunchUri.Value);

            return;

        }

        await NavigationService.NavigateAsync($"{nameof(NavigationPage)}/{StartPage}");

    }

    public sealed class AppBuilder

    {

        private Uri launchUri;

        private IPlatformInitializer platformInitializer;

        private AppBuilder()

        {

        }

        public static AppBuilder GetBuilder()

        {

            return new AppBuilder();

        }

        public App Create()

        {

            var app = new App(platformInitializer)

            {

                LaunchUri = launchUri.ToMaybe()

            };

            return app;

        }

        public AppBuilder WithLaunchUri(Uri uri)

        {

            launchUri = uri;

            return this;

        }

        public AppBuilder WithPlatformInitializer(IPlatformInitializer initializer)

        {

            platformInitializer = initializer;

            return this;

        }

    }

}

We are facing the issue in MAUI after upgrade from Xamarin the prism dll not found any alter native in MAUI, above code is the app.xaml.cs code where IPlatformInitializer , Container and NavigationService through error not found.

Please help if any alternative for Prism.form dll in MAUI

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,967 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 36,951 Reputation points Microsoft Vendor
    2024-05-02T02:57:29.0133333+00:00

    Hello,

    Xamarin.Forms has a different architecture than MAUI, where dependency injection is the first concept in MAUI. Therefore Prism.Forms is not applicable to MAUI.

    Since Microsoft Q&A does not currently support third-party plugins, for Prism migration issues, you can search for Migrating from Prism.Forms keyword in your browser and the official repository of Prism.MAUI to migrate and adapt it to the MAUI project.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments