Simple Injector with mediatR

Can anybody help me out figuring out what I'm doing wrong with the injection of mediatr class in my project. I'm using simple injector to build all the injections, plus Mediator, CQRS pattern and graphql I know Mediator class has 2 constructors, but that's the code I see at the projects I worked. the code here https://paste.mod.gg/vtrlktxvrnvd/0
BlazeBin - vtrlktxvrnvd
A tool for sharing your source code with the world!
No description
3 Replies
Angius
Angius2w ago
The error is quite clear If you inject an IMediator somewhere... what instance do you expect to get? The documentation is also quite clear on how you're supposed to inject MediatR: https://github.com/jbogard/MediatR?tab=readme-ov-file#registering-with-iservicecollection Ah, wait, nevermind. I missed the fact that you're using some weird DI container In that case, see what .AddMediatR() does and replicate it: https://github.com/jbogard/MediatR/blob/master/src/MediatR/MicrosoftExtensionsDI/ServiceCollectionExtensions.cs
Giovani Ferro
Giovani Ferro2w ago
tks bro
SleepWellPupper
You're registering an interface onto an interface. Your registration has to register an implementation (concrete type) onto the IMediator interface. Also, if you find yourself unable to integrate MediatR with SimpleInjector, you might want to look into the SimpleInjector ASP integration guides. They showcase how you can use the default DI container (to register MediatR properly) and then cross-wire into a SimpleInjector Container So you would be able to resolve services from the default container via the SimpleInjector container