jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
11k stars 1.16k forks source link

Update Referenced MediatR.Extensions.Autofac.DependencyInjection #861

Closed jdmoore1618 closed 1 year ago

jdmoore1618 commented 1 year ago

The current version of your nuget package is currently referencing V9 of MediatR.Extensions.Autofac.DependencyInjection. With V9, I am unable to start my project within the ConfigureContainer ServiceProviderFactory hook-in. I am receiving the error, " System.TypeLoadException: Could not load type 'MediatR.ServiceFactory' from assembly 'MediatR, Version=12.0.0.0, Culture=neutral, PublicKeyToken=bb9a41a5e8aaa7e2'."

Old code referencing V9 through your nuget package:

public void ConfigureContainer(ContainerBuilder builder)
{
    var assemblies = AssemblyRegistration.GetAllAssembliesToScan(Assembly.GetExecutingAssembly()); // Some extension method to grab all assemblies

    builder.RegisterMediatR(assemblies);
}

I directly referenced MediatR.Extensions.Autofac.DependencyInjection V10 and I am able to start my project with a tiny update.

Updated code referencing V10 through my direct reference:

public void ConfigureContainer(ContainerBuilder builder)
{
    var assemblies = AssemblyRegistration.GetAllAssembliesToScan(Assembly.GetExecutingAssembly()); // Some extension method to grab all assemblies

    var configuration = MediatRConfigurationBuilder
        .Create(assemblies)
        .WithAllOpenGenericHandlerTypesRegistered()
        .Build();

    builder.RegisterMediatR(configuration);
}
jbogard commented 1 year ago

This looks like it's an issue with the MediatR.Extensions.Autofac.DependencyInjection package, which I don't own/control/maintain.

jdmoore1618 commented 1 year ago

You are correct. I am referencing V9 in an interdependent project please disregard.