I'm a bit lost here. I am trying to set up a very simple app with Prism.Autofac.Wpf 7;
App.xaml.cs:
public partial class App
{
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>(); // this point won't even be reached
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
}
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
base.ConfigureModuleCatalog(moduleCatalog);
}
}
App.xaml:
<prism:PrismApplication x:Class="MyNamespace.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:prism="http://prismlibrary.com/"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</prism:PrismApplication>
upon startup, this throws a DependencyResolutionException at some point after RegisterTypes() has been called, but before CreateShell() is called:
None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Prism.Autofac.AutofacServiceLocatorAdapter' can be invoked with the available services and parameters:
Cannot resolve parameter 'Autofac.IContainer container' of constructor 'Void .ctor(Autofac.IContainer)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
Naively going by the error message and trying to register the IContainer myself, I have tried
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
var builder = containerRegistry.GetBuilder();
// .. register a few modules here ..
var container = builder.Build();
containerRegistry.RegisterInstance<IContainer>(container);
}
but then I'll get an InvalidOperationException: "Build() or Update() can only be called once on a ContainerBuilder."
I'm a bit lost here - what's going wrong in this minimal example?!
Thanks