Open ghost opened 5 years ago
ConnectR depends on MediatR. MediatR depends on Dependency Injection. MediatR is calling it's GetHandler function, using the ServiceFactory (i.e. DI container). The DI container is probably returning null or throwing. MediatR catches and rethrows, setting the InnerException. You have to look at InnerException to find where your problem is.
In your case, you're using Autofac (that information is not knowable from your post). There will probably 2 or 3 layers of InnerException to dig through. Or, carefully read the Autofac exception. They are hard to read, but they actually have all the information in them.
You can reproduce the issue by getting an instance of ILifetimeScope
and try to lifetimeScope.Resolve<IRequestHandler<TRequest,TResponse>>()
.
The issue shouldn't have anything to do with WCF, other than each application has it's own DI container setup. The resolution is the problem will probably be in DI setup. The IRequestHandler<,>
may be registered and there's a dependency that is not registered (possibly HttpClient that needs to be registered .AsSelf()
.
If the handler is not registered, the issue may be with not running .RegisterAssemblyMediatorHandlers<>()
or .RegisterMediatorRequestWrappers<>()
with the proper class. It should be a handler. The extensions will register the assembly that contains that handler.
Let me know how it goes.
Issue: Not working in WCF. It is working in console
Setup: builder.RegisterHttpClientRequestHandler
at MediatR.Internal.RequestHandlerBase.GetHandler[THandler](ServiceFactory factory) at MediatR.Internal.RequestHandlerWrapperImpld2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Pipeline.RequestPostProcessorBehavior`2.d 2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
2.<>c__DisplayClass0_0.<Handle>g__Handler|0() at MediatR.Pipeline.RequestPreProcessorBehavior
2.