Search code examples
asp.net-coredryioc.net-8.0

How do I find out from where a registration in the DryIoC container was invoked?


I'm using DryIoC in (combination with ASP.NET Core) and am getting a DryIoc.ContainerException seemingly because of a wrong registration.

Registering implementation type Microsoft.Extensions.Logging.ConsoleFormatterConfigureOptions is not assignable to service type Microsoft.Extensions.Options.IConfigureOptions<Microsoft.Extensions.Logging.Console.JsonConsoleFormatterOptions>.'

I created a DryIoC container and using it in the WebBuilder:

WebApplicationBuilder? builder = WebApplication.CreateBuilder( args );
builder.Host.UseServiceProviderFactory(
    new DryIocServiceProviderFactory(DiContainer));

How can I find out, where this registration is done?

Or someone can directly tell me what to do to get rid of the error...

Update:

I found that the registration comes from Microsoft.Extensions.Logging.ConsoleLoggerExtensions. But still do not know why.

Here is the example code if you start with a new asp.net core project:

using DryIoc.Microsoft.DependencyInjection;

namespace WebApplication1
{
    public class Program
    {
        public static void Main( string[] args )
        {
            var container = new DryIoc.Container();

            var builder = WebApplication.CreateBuilder( args );
            builder.Host.UseServiceProviderFactory( new DryIocServiceProviderFactory( container ) );

            var app = builder.Build();
        }
    }
}

builder.Build() raises the exception.

Thanks


Solution

  • Problem is caused by using older versions of DryIoc.dll (4.0.5) and DryIoc.Microsoft.DependencyInjection (3.0.3) with .NET 8.

    After upgrading to latest stable versions the issue is gone.

    Many thanks to Guru Stron for the support!