Prism: IModuleCatalog could not be resolved in UWP

Created on 2 Dec 2018  路  10Comments  路  Source: PrismLibrary/Prism

Description

I cannot initalize a module because I receive an error: IModuleManager could not be resolved. This is strange as prior to resolving phase it is registered in PrismApplication.RegisterRequiredTypes().

Originally, the error rises in PrismApplication.InitializeModules() in line 195. If you try to resolve it before this method kicks in (but after instance was registered) same thing happens.

Steps to Reproduce

  1. Create a new simple module
  2. Add it by overriding ConfigureModuleCatalog()
  3. Turn on debugging (you may need to turn mixed mode debugging to see the issue in ouput window)

Expected Behavior

Initialization of modules is possible.

Actual Behavior

An error is rised:
Exception thrown at 0x00007FFC31EA5299 (KernelBase.dll) in ElkaUWP.Core.exe: WinRT originate error - 0x80131500 : 'Unity.Exceptions.ResolutionFailedException: Resolution of the dependency failed, type = 'Prism.Modularity.IModuleManager', name = '(none)'. Exception occurred while: while resolving. Exception is: InvalidOperationException - The current type, Prism.Ioc.IContainerExtension, is an interface and cannot be constructed. Are you missing a type mapping?

Basic Information

  • Version with issue: 7.2.0.690-ci (Prism.Windows.Unity)
  • Last known good version: Unknown
  • IDE: VS2017 Enterprise

Reproduction Link

Example.7z

UWP bug

All 10 comments

I made a further investigation on this issue.
It seems that IModuleManager could not be resolved because IModuleCatalog could not be solved in the first place.

Workaround:
By overriding RegisterRequiredTypes() i managed to find out that if one replaces RegisterSingleton<>() by Register<>() for IModuleCatalog, the module will be loaded.

Because I need to work with IModuleCatalog only once (and I am not going to use its powerful features from WPF, just for cosmetic project structure splitting) this is okay, as it won't cause memory leak...

I am still trying to understand where the bug lies, but for now I think am missing something essential while browsing code.

Yes UWP cannot load dinamically DLLs so the ModuleManager functionality can be only for project structure purposes.

@totht91 could you elaborate on that?

The problem is that the IContainerExtension is not being registered with the container. So the IModuleManager can't be created. Just add containerRegistry.RegisterInstance(Container) and it should work. Let me know if that works.

@brianlagunas Unfortunately, registering the container in the registry at the beginning of RegisterRequiredTypes() didn't fix the issue.

However, containerRegistry.RegisterInstance((IContainerExtension)Container); does fix it.

Yeah.... sorry, you need to provide the interface containerRegistry.RegisterInstance<IContainerExtension>(Container)

@brianlagunas this does not work as

IContainerProvider is not assignable to IContainerExtension

Not strange because IContainerExtension implements IContainerProvider but not the other way :)

it will work when I do it :)

fixed

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dansiegel picture dansiegel  路  101Comments

brianlagunas picture brianlagunas  路  42Comments

tboogh picture tboogh  路  36Comments

mohammedmsadiq picture mohammedmsadiq  路  45Comments

softwaretirol picture softwaretirol  路  26Comments