Error after Removing Mediatr and Adding Mediator.. Issue in the wiring up. #218
Replies: 4 comments
-
|
I added this too.. Still the same error builder.Services.AddMediator(options => |
Beta Was this translation helpful? Give feedback.
-
|
Sorry if I’m mistaken, but are your handler and controller in the same |
Beta Was this translation helpful? Give feedback.
-
|
I'm not sure what could be wrong here as I have no insight into the project setup here. You could take a look at some samples in this repo to see if you can spot the issue or you can post a repro if you would like more help |
Beta Was this translation helpful? Give feedback.
-
|
A small insight in my process, which might aid someone with a similar issue Our project structure looks something like this:
I installed the Mediator.SourceGenerator nuget package in the webapi project as per the documentation. services.AddMediator(cfg => We have a unit test which validates whether it can resolve all interfaces from the collection, which failed, unable to resolve any handler. This can also be validated by looking at the generated code in: [project where sourcegenerator is installed] -> Dependencies -> Analyzers -> Mediator.SourceGenerator -> Mediator.g.cs. Hope this helps |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
fail: Cpa.Fas.ProductMs.WebApi.Middleware.ExceptionHandlingMiddleware[0]
$>b__0_3>d.MoveNext() in C:\Source\fas-product-ms\src\presentation\Cpa.Fas.ProductMs.WebApi\Program.cs:line 73An unhandled exception occurred: No handler registered for message type: Cpa.Fas.ProductMs.Application.Products.Commands.CreateProduct.CreateProductCommand
Mediator.MissingMessageHandlerException: No handler registered for message type: Cpa.Fas.ProductMs.Application.Products.Commands.CreateProduct.CreateProductCommand
at Mediator.Mediator.ThrowMissingHandler(Object msg) in C:\Source\fas-product-ms\src\core\Cpa.Fas.ProductMs.Domain\obj\Debug\net8.0\Mediator.SourceGenerator\Mediator.SourceGenerator.IncrementalMediatorGenerator\Mediator.g.cs:line 1077
at Mediator.Mediator.ThrowInvalidRequest[T](T msg, String paramName) in C:\Source\fas-product-ms\src\core\Cpa.Fas.ProductMs.Domain\obj\Debug\net8.0\Mediator.SourceGenerator\Mediator.SourceGenerator.IncrementalMediatorGenerator\Mediator.g.cs:line 1102
at Mediator.Mediator.Send[TResponse](IRequest
1 request, CancellationToken cancellationToken) in C:\Source\fas-product-ms\src\core\Cpa.Fas.ProductMs.Domain\obj\Debug\net8.0\Mediator.SourceGenerator\Mediator.SourceGenerator.IncrementalMediatorGenerator\Mediator.g.cs:line 846 at Cpa.Fas.ProductMs.WebApi.Controllers.ProductsController.CreateProduct(CreateProductRequestViewModel request) in C:\Source\fas-product-ms\src\presentation\Cpa.Fas.ProductMs.WebApi\Controllers\ProductsController.cs:line 38 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask)at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Program.<>c.<<
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context, HttpLoggingOptions options, HttpLoggingAttribute loggingAttribute, HttpLoggingFields loggingFields)
at Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext context, HttpLoggingOptions options, HttpLoggingAttribute loggingAttribute, HttpLoggingFields loggingFields)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Cpa.Fas.ProductMs.WebApi.Middleware.ExceptionHandlingMiddleware.InvokeAsync(HttpContext httpContext) in C:\Source\fas-product-ms\src\presentation\Cpa.Fas.ProductMs.WebApi\Middleware\ExceptionHandlingMiddleware.cs:line 20
Beta Was this translation helpful? Give feedback.
All reactions