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?