Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Services registered with ConfigureModuleCatalog not available in OnInitialized #3288

Open
Codelined opened this issue Dec 1, 2024 · 0 comments
Assignees

Comments

@Codelined
Copy link

Description

Services registered as part of a module later registered with the ConfigureModuleCatalog method cannot be resolved in the OnInitialized method.
However, services registered with RegisterTypes method are resolved correctly.__

Steps to Reproduce

  1. Create a new MAUI single project app
  2. Install latest Prism.DryIoc.Maui (9.0.537)
  3. Create interface and implementation of that interface
  4. Create implementation of IModule and register interface and it's implementation
  5. Register IModule implementation in ConfigureModuleCatalog
  6. Try to resolve service in OnInitialized

Example of solution that crashes on start when service is to be resolved:
PrismBugReport.zip

Platform with bug

.NET MAUI

Affected platforms

Android

Did you find any workaround?

Workaround is to register service in RegisterTypes method which defeats the purpose of ConfigureModuleCatalog method.

Relevant log output

Prism.Ioc.ContainerResolutionException
  Message=An unexpected error occurred while resolving 'PrismBugReport.IModuleService'
  Source=Prism.Container.DryIoc
  StackTrace:
   at Prism.Container.DryIoc.DryIocContainerExtension.Resolve(Type type, ValueTuple`2[] parameters) in /_/src/Prism.Container.DryIoc/DryIocContainerExtension.cs:line 321
   at Prism.Container.DryIoc.DryIocContainerExtension.Resolve(Type type) in /_/src/Prism.Container.DryIoc/DryIocContainerExtension.cs:line 292
   at Prism.Ioc.IContainerProviderExtensions.Resolve[IModuleService](IContainerProvider provider) in /_/src/Prism.Container.Abstractions/IContainerProviderExtensions.cs:line 16
   at PrismBugReport.MauiProgram.<>c.<<CreateMauiApp>b__0_4>d.MoveNext() in C:\Lab\PrismBugReport\PrismBugReport\MauiProgram.cs:line 28
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
   at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 37
   at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net9.0/android-35/mcw/Java.Lang.IRunnable.cs:line 59
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants