PrismLibrary / Prism.Maui

This is an experimental repo. The code here will eventually be merged into the main Prism repo as a full fledged platform at which time this repo will be archived.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MAUI RC1 (VS2022 17.2.0 Preview 3.0): StackOverflow caused by recursion in PrismServiceProviderFactory.cs

UweReisewitz opened this issue · comments

Hi,
this is what I have tested so far:

  1. Install VS 2022 Version 17.2.0 Preview 3.0 (I have updated from the previous Preview)
  2. Clone Master Branch
  3. Update all NuGet packages
  4. Remove unnecessary entries from project file PrismMauiDemo.cs:
 <ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
    <!-- Required - WinUI does not yet have buildTransitive for everything -->
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
  </ItemGroup>
	
  <PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
    <OutputType>WinExe</OutputType>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>
	
  <ItemGroup>
    <PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.1" />
    <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.2" />
  </ItemGroup>
  1. Remove line 49 in Prism.Maui\sample\PrismMauiDemo\Platforms\Windows\Package.appxmanifest:
    <uap:SplashScreen Image="Assets\appiconfgSplashScreen.png" />
  2. Rebuild Solution
  3. Run PrismMauiDemo
  4. The first problem is in Prism.Maui\src\Prism.Maui\Modularity\ModuleManager.cs
  5. LoadModules crashes with:
DryIoc.ContainerException: 'code: Error.RegisteringImplementationNotAssignableToServiceType;
message: Registering implementation type MauiModule.ViewModels.ViewAViewModel is not assignable to service type MauiModule.Views.ViewA.'
  1. Solution: See #6 (comment)
  2. The application now crashes with a stackoverflow in Prism.Maui\src\Prism.Maui\Ioc\PrismServiceProviderFactory.cs:
    internal class ServiceScopeFactory : IServiceScopeFactory
    {
        private IServiceProvider _services { get; }

        public ServiceScopeFactory(IServiceProvider services)
        {
            _services = services;
        }

        public IServiceScope CreateScope()
        {
            return _services.CreateScope();
        }
    }
  1. Reason: return _services.CreateScope() creates a new ServiceScopeFactory which causes the recursion

Now I'm stuck. If I could be of any help please let me know.

Best Regards
Uwe

Resolved by #18