1

I have a WPF Prism application with Unity container. I would like to add the Serilog logging service. So I override RegisterTypes as follows:

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
            
  containerRegistry.RegisterServices(serviceCollection =>
        serviceCollection.AddLogging(logbuilder => logbuilder.AddSerilog(dispose: true)));
}

I have following Nuget packages installed:

  • Prism.Core
  • Prism.Unity
  • Prism.Unity.Extensions
  • Prism.Wpf

When resolving het MainWindow type from the container I get the error InvalidOperationException: No public constructor is available for type System.IServiceProvider

Related information:

I can get it to work when I follow the implementation documented in https://www.andicode.com/prism/wpf/logging/2021/05/21/Logging-In-Prism.html but this is not the same methodology as for Prism Xamarin Forms and Dryloc or Unity.

What is the reason for the difference between WPF and Xamarin Forms?

0 Answers0