I tried working around #28 by implementing my behavior as a pre-processor instead (the actual behavior is validation, so this fits well with my use-case anyway), but now the application fails to start, with the following error:
Unhandled Exception: System.ArgumentException: Open generic service type 'MediatR.Pipeline.IRequestPreProcessor`1[TRequest]' requires registering an open generic implementation type.
Parameter name: descriptors
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.Populate(IEnumerable`1 descriptors)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory..ctor(IEnumerable`1 descriptors)
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable`1 serviceDescriptors, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Web.Program.BuildWebHost(String[] args) in C:\Work\my-project\Web\Program.cs:line 21
at Web.Program.Main(String[] args) in C:\Work\my-project\Web\Program.cs:line 17
The service registration is, as before, just services.AddMediatR(typeof(FooHandler)), and the implementation of the pre-processor is
public class FooPreProcessor : IRequestPreProcessor<FooCommand>
{
public Task Process(FooCommandrequest, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
Am I missing something here, or is this the same problem as #12?
I tried working around #28 by implementing my behavior as a pre-processor instead (the actual behavior is validation, so this fits well with my use-case anyway), but now the application fails to start, with the following error:
The service registration is, as before, just
services.AddMediatR(typeof(FooHandler))
, and the implementation of the pre-processor isAm I missing something here, or is this the same problem as #12?