Using the last preview lib, Prism.Autofac.Wpf cannot run, throw System.ArgumentNullException .
public partial class App : PrismApplication
{
protected override Window CreateShell()
{
return this.Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<MainWindow>();
}
}
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
>
</Application.Resources>
Show the MainWindow app。
Throw System.ArgumentNullException.
I checked the code, the problem is the containerRegistry.GetContainer() return null, because of PrismApplicationBase not call IContainerExtension.FinalizeExtension() yet.
protected override void RegisterRequiredTypes(IContainerRegistry containerRegistry)
{
base.RegisterRequiredTypes(containerRegistry);
containerRegistry.RegisterSingleton
**_serviceLocator = new AutofacServiceLocatorAdapter(containerRegistry.GetContainer());**
containerRegistry.RegisterInstance<IServiceLocator>(_serviceLocator);
}
@A71014073 please include a reproduction link
I've confirmed this problem, and it seems to be limited to Autofac, not sure why this hasn't failed in our tests....
cc: @brianlagunas
I found the problem. The issue is that Autofac is now immutable, which means that we can't create the ServiceLocator instance until after the container has been finialized, AND we can't register the ServiceLocator instance after the container has been finalized because it's immutable.
I may be able to fix it, but that would require writing a base app class specifically for autofac.
I think we should just drop support for Autofac. It has proven to be a real pain in the ass.
Not to mention that Autofac does not support modules at this time since it is an immutable container
Fixed. You can test it out in the latest CI build. Though, you won't have module support.
It seems to be back at 55b64c0d7f37d6361be1b2a1fefb397fcd04ccff on Sep 24, 2018
@okadabasso Autofac support is being dropped. Since it has changed to be immutable, it can no longer support the features of Prism. If you wish to continue using autofac, you will have to write your own extension for it. You would be better off using a different container.
thanks @brianlagunas
@brianlagunas So if Autofac support is being dropped for Prism, I'm thinking of using the Unity container. I'm looking for the easiest container to wire up and the one with the best performance/speed?
Then you want DryIoc
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.