Frustrating error I have never seen before and cannot shake it. Using simple Azure HTTP Function in .NET 6 and MediatR 12 and getting the following in Startup.cs for DI of MediatR:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Boolean Microsoft.Extensions.DependencyInjection.ServiceDescriptor.get_IsKeyedService()'.Source=MediatR
StackTrace:
at MediatR.Registration.ServiceRegistrar.<>c.b__12_0(ServiceDescriptor service) at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.<OfTypeIterator>d__61
1.MoveNext() at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func
2 predicate) at MediatR.Registration.ServiceRegistrar.RegisterBehaviorIfImplementationsExist(IServiceCollection services, Type behaviorType, Type subBehaviorType) at MediatR.Registration.ServiceRegistrar.AddRequiredServices(IServiceCollection services, MediatRServiceConfiguration serviceConfiguration) at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddMediatR(IServiceCollection services, MediatRServiceConfiguration configuration) at TheMove.Functions.Startup.Configure(IFunctionsHostBuilder builder) in C:\Users\shamu\source\repos\TheMove\TheMove.Functions\Startup.cs:line 25 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices(IWebJobsStartup startup, WebJobsBuilderContext context, IWebJobsBuilder builder, ILoggerFactory loggerFactory) at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup(IWebJobsBuilder builder, Type startupType, WebJobsBuilderContext context, ILoggerFactory loggerFactory) at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup(IWebJobsBuilder builder, IWebJobsStartupTypeLocator startupTypeLocator, WebJobsBuilderContext context, ILoggerFactory loggerFactory) at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions.<>c__DisplayClass7_0.b__1(HostBuilderContext context, IWebJobsBuilder webJobsBuilder)
Source Code:
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
[assembly: FunctionsStartup(typeof(TheMove.Functions.Startup))]
namespace TheMove.Functions
{
public class Startup : FunctionsStartup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public Startup() { }
public override void Configure(IFunctionsHostBuilder builder)
{
if(builder != null)
{
var assembly = AppDomain.CurrentDomain.Load("TheMove.Application");
builder.Services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssembly(assembly);
});
}
}
}
}