0

I am currently evaluating PRISM (8.1.97) and trying to prove that module initialization failures can be easy to debug.

I am following the guidance from the below link with regards module initialization errors because of a failure to register a required service:

https://prismlibrary.com/docs/dependency-injection/resolution-errors.html

My test code looks like:

    protected override void InitializeModules()
    {
        var manager = Container.Resolve<IModuleManager>();

        manager.LoadModuleCompleted += onModuleLoaded;

        manager.Run();
    }

    private static void onModuleLoaded(object? sender, LoadModuleCompletedEventArgs e)
    {
        if (e.Error is ContainerResolutionException resolutionException)
        {
            onContainerResolutionException(resolutionException);
        }
    }

On removing a required module that registers a service and running the application, onModuleLoaded is called for each successfully loaded module but an exception of type Prism.Modularity.ModuleInitializeException is thrown instead of onModuleLoaded being called with an event argument that contains an error.

Is there something that needs to be set, not mentioned in the article, for this functionality to work?

  • Are you looking for [this](https://stackoverflow.com/questions/36332287/how-to-debug-unity-resolution/52971253#52971253)? – Haukinger Nov 02 '21 at 12:27
  • @Haukinger possibly a solution, I am using DryIoc as opposed to Unity currently. No real reason for this other than that was what was suggested in the PluralSight course on the topic. I was hoping to make the solution in the PRISM documentation work as it seemingly requires less code and is dependency injection solution agnostic. – gavarial Nov 02 '21 at 14:58

0 Answers0