565 questions
0
votes
0
answers
30
views
Best Practices for Returning Error Descriptions or Error Codes in a Validation Flow [closed]
I'm currently using the ErrorOr library along with MediaR in my project. I want to implement validation logic in a command and have some questions about the best practices for returning errors.
Here's ...
0
votes
0
answers
24
views
Dependency Injection MediatR with PostgreSQL DbContext
I'm trying to set up a template for myself using .NET 8, PostgreSQL as database and CQRS pattern (with MediatR library).
I've done all the configuration, but when I try a simple QueryHandler, this is ...
0
votes
0
answers
45
views
How to register MediatR in WPF application
I'm experimenting with DDD in an MVVM application.
It is a basic customer system.
When I add an address I want to validate it does not exist in the database.
This can be done by using a Domain Event ...
0
votes
0
answers
16
views
Getting my IDE to show autocompletion for only generic typ specified in interface (using MediatR, C#)
I want to ensure that my IDE, during autocomplete for function parameters, suggests only (or at least prioritizes) the parameters that are allowed in the function. Specifically, this pertains to an ...
0
votes
0
answers
35
views
Open generic service type '[TRequest,TResponse]' does not equal open generic implementation type '[TRequest,TResponse,T]
Using net9 I have the following MediaTr Behavior:
public class ValidationBehavior<T1, T2, T3> : IPipelineBehavior<T1, T2> where T1 : IRequest<T2> where T2 : Outcome<T3>, new() {...
1
vote
1
answer
52
views
Is it possible to write one handler for multiple notifications in MediatR
I have such hierarchy
class Notification : INotification
{
public string Message { get; set; }
}
class Notification1 : Notification
{
public int Count { get; set; }
}
class Notification2 : ...
0
votes
1
answer
59
views
Handlers are not called for some notifications published with MediatR depending on class hierarchy and generics
Please find below an explanation of the problem, and a simple but almost complete repro (.Net 8 / MediatR 12.4.1), usable in Linqpad or Console app.
I have a barely complex hierarchy of Notifications ...
0
votes
0
answers
16
views
Mediatr different handler response depending on boolean flag?
In my controller I want to return two different responses depending on includeUsers boolean. The problem is my handler right now returns a BuddyResponse dto, and I want it to return BuddyResponse dto ...
0
votes
1
answer
42
views
What kind of commands/queries can be created with MediatR?
What kind of commands/queries can be created with MediatR? I understand that I can add CRUD operations but what about signing in, getting user claims, sending mails etc.? I can add them too? Are there ...
2
votes
2
answers
68
views
Inherit from a generic base class in C#
I want to inherit from a generic TEntity but I get this error:
Compiler Error CS0689
Cannot derive from 'identifier' because it is a type parameter
Base classes or interfaces for generic classes ...
0
votes
1
answer
67
views
IPipelineBehavior ValidationBehavior doesn't get triggered when registered in MediatR
I'm replacing all exception with Result<T> by the LangExt library. The problem is ValidationBehavior doesn't even get triggered. It used to trigger when the method signature used to be public ...
0
votes
0
answers
37
views
MediatoR 12.4.0 not publishing events, INotificationHandler.Handle is never hit
I am trying to play around a little with MediatR and MassTransit, in fact I'm trying to make a WebAPI developed as a Modular Monolith using a slightly modified version of Clean Architecture (...
0
votes
0
answers
50
views
MediatR+Autofac NotificationHandler decorator pattern strange behaviour
I'm having a very strange issue with decorator pattern using MediatR (12.4.0) and Autofac (8.0.0) but I really cannot understand wether the problem is concerning Autofac, MediatR or (more probably) my ...
0
votes
0
answers
86
views
Problem registering fluent validation behavior with MediatR with minimal apis
I have an app setup with controllers and a Fluent validation Behavior setup with MediatR, it's working when the request is in an MVC controller but when i try making the same request from a minimal ...
1
vote
0
answers
40
views
How to use MediatR in order to navigate between views in avalonia ui
I want to use the MediatR to navigate between views in avalonia ui, I have looked on the web didn't find much information and the avalonia documentation doesn't contain any info either.
I need help, ...
0
votes
2
answers
78
views
Second Mediator Call Fails with ObjectDisposedException in ASP.NET Core Using Autofac: "Instances cannot be resolved as it has already been disposed"
I am trying to run two mediator calls inside a method. For some reason, the second mediator call always fail. I am expecting both calls to run without error. The full error message is:
System....
0
votes
1
answer
139
views
Strategies for Maintaining Complex Mediator/CQRS Data Flows in .NET
I'm working on a .NET project using Mediator and the CQRS pattern. As the complexity of my application grows, I'm facing challenges in managing complex data flows that involve numerous handlers from ...
0
votes
0
answers
40
views
Saving changes on database before Unit of Work commit within MediatR CommandHandler
Project info
I'm using CQRS with MediatR and Unit of Work pattern. SignalR for real-time communication with client side.
What am I trying to achieve?
I have a Domain entity that represents the ...
2
votes
1
answer
112
views
ASP.NET Core - How to resolve error in Fluent Validation
I have this code in an ASP.NET Core 8 Web API using Fluent Validation:
public class CreateBranchBulkUploadCommand : IRequest<Response<string>>
{
public IFormFile File { get; set; }
}
...
0
votes
0
answers
84
views
How to chain requests in Mediatr12 with transactions
I am trying to implement a MediatR request pipeline for user registration following the CQRS principle. The scenario is as follows:
The CreateCompanyHandler will create a company or tenant, if this ...
0
votes
0
answers
94
views
How to save all changes in one transaction while using MediatR
I'm using MediatR to create an order with two types of tasks. Each task has its own command, and I would like to use a transaction to ensure that both types of tasks are saved, or none are saved.
I ...
1
vote
1
answer
349
views
How to resolve threading issues with DbContext on .NET Core, EF Core
Got threads issue on EF Core 8.0, .NET 8, I got this issue how to overcome this?
Error:
A second operation was started on this context instance before a previous operation completed. This is usually ...
0
votes
1
answer
433
views
How to use SignalR Hub in class library project
How to use Signalr Hub class in class library project?
I do not see possible reference to Hub.
In application project (class library) I do not have access to this class
In Web project which is ...
0
votes
0
answers
74
views
The timing of publishing for domain events using Mediatr
I can't see why doing a savechanges interceptor to fire off the domain events is helpful or what it adds to an architecture as opposed to just publishing (eg await _mediator.Publish(domainEvent)) them ...
0
votes
0
answers
77
views
Using OData Expand with DTOs
I got this simple API in .NET 8, added Mediatr and OData packages as well as AutoMapper
I'm trying not to expose my data layer stuff to the API layer, so everything needs to be done via mediator ...
1
vote
1
answer
106
views
ASP.NET Core - Error CS0535 'PerformanceBehaviour<TRequest, TResponse>' does not implement interface member 'IPipelineBehavior
In ASP.NET Core-8 With MediatR I got this error:
Error CS0535 'PerformanceBehaviour<TRequest, TResponse>' does not implement interface member 'IPipelineBehavior<TRequest, TResponse>....
0
votes
0
answers
47
views
Mediatr behavior pipeline does not work in new Blazor App
I'm trying to create a new Blazor App in .NET 8, using Mediatr, and I created a custom behavior pipeline for MediatR to handle some validations, using FluentValidation. However it seems to be getting ...
0
votes
0
answers
93
views
How to implement Mediatr INotification handler as a singleton
Maybe I'm trying to use the wrong tool for the job here and will happily take advice on better ways to implement this project.
I have an application that broadly processes stock market prices, price ...
0
votes
0
answers
76
views
Mediatr CQRS using generics in C#
Why can't the call to create an instance of the Mediatr command in the following code work? It can't seem to find the proper instance of the generic. Basically it's specifically looking for ...
0
votes
0
answers
390
views
gRPC Invalid content-type value: text/html when upgrading to .NET 8
I am working on upgrading the solution from .NET 7 to .NET 8. Identical code works on .NET 7, but on .NET 8 I start getting exceptions on client side:
Grpc.Core.RpcException: 'Status(StatusCode="...
0
votes
1
answer
258
views
MediatR: Global exception handler is being executed multiple times
I am implementing CQRS in my ASP.NET Web API using MediatR. To catch and log exceptions to the database, I want to use a global exception handler:
public class GlobalRequestExceptionHandler<...
0
votes
1
answer
230
views
Blazor The input does not contain any JSON tokens
I am trying to pass an order number to Mediator to look up.
Here are examples of order numbers:
GRE_A14Y9-TS72
ANN_ALJB6-E6ZN
In localhost, I am passing them on the url like this:
https://localhost:...
0
votes
1
answer
708
views
MediatR IRequestHandler fails to resolve scoped service when ISender is injected through ICarterModule constructor
Im working on a Clean Architecture course at the moment and found myself trying to structure my minimal api using Carter package. The problem I am currently struggling to understand is why mediatR ...
0
votes
0
answers
48
views
How can I call MediatR handlers outside the api project of my app?
I have a handler which I want mediator to invoke it outside .net runtime, here is my sample code of what I have in mind:
public class SageSync
{
public async Task ExecuteSync()
{
//I ...
5
votes
1
answer
3k
views
Keyed service dependency problem when injecting in Program.cs
I wrote a interface and implemented it in 3 services, but when I used AddKeyedScoped to inject these to project I get the following error.
Unhandled exception. System.InvalidOperationException: This ...
0
votes
0
answers
357
views
Unable to enqueue a job on Hangfire due to abstract classes/DI
When enqueuing a job to Hangfire, it seems like the DI is not working as it should, since it seems to be trying to instantiate a class out of an interface.
In this example, trying to enqueue a job ...
0
votes
0
answers
43
views
Dynamic MediatR response
Let's say I have these classes:
class StuffResponse { ... }
class StuffButLongerResponse : Response { ... }
class StuffCommand : IRequest<???>
class EverythingRelatedToStuffCommandHandler : ...
0
votes
1
answer
53
views
DDD and creating aggregate roots related to each other in single command
I am remodeling .net core application and facing following problem. In said application I identified potential aggregate roots, lets say three of them Exam, Patient, ServiceProvider should be created ...
1
vote
1
answer
247
views
the newest Mediatr and a handler with a synchronous method Handle: "not all code paths return a value"
I have the newest MediatR (12.2.0) and I have a synchronous method which returns nothing. Do I really need to use "async Task" instead of "Task"? Because the following method gives ...
1
vote
1
answer
114
views
Register all IMediatR classes
Is there any form to avoid registering all the assemblies that implement IMediator service?
I try using these options but none of them helps me:
builder.Services.AddMediatR(Assembly....
1
vote
1
answer
2k
views
Why is MediatR Giving me the error: System.InvalidOperationException: No service for type 'MediatR.IRequestHandler` when I my .net core 8.0 program.cs
I am getting the following error when I call (MediatR) ISender.Send(<Request Object>) in my .net core 8.0 web API project. The solution in VS is a Web API project and a C# Library where all of ...
0
votes
0
answers
134
views
Using Mediatr inside Unity game engine
I use Mediatr at work so I thought I'd give it a try inside Unity Game Engine just because I find it interesting to play around with different ways to do things. I was able to import the library just ...
0
votes
0
answers
55
views
What is the alternate solution for AddMediatR in the .NET Core Web API Program.CS file?
I'm creating a application called "Employee Salary Management System", using CQRS and MediatR so when I add this below line on the Program.cs file then I got and compilation error so how ...
0
votes
0
answers
93
views
MediatR notification handler dispose behaviour
I'm implementing a .NET 8 worker service with Quartz.NET & MediatR. The flow of which is:
Gets triggered after certain intervals (defined by cron expression) by
Quartz.NET job scheduler --> ...
0
votes
1
answer
474
views
MediatR 12.2.0 behavior
I am trying to implement simple logging behavior using MediatR, and I tried some registration in Program.CS but none of them didn't work.
using MediatR;
using Microsoft.Extensions.Logging;
namespace ...
0
votes
0
answers
236
views
MediatR Pattern CleanArchitecture with ASP.NET Core Web API
I am new to ASP.NET and using clean architecture with MediatR. I am now wondering whether I have taken a wrong turn somewhere in my understanding here. I am a little confused right now.
Things that I ...
0
votes
1
answer
612
views
Error constructing handler for request of type MediatR.IRequestHandler
i am getting mediatr error in a handler i have added dependency in Startup.cs still i am getting above error i have AddInfoRequestHandler which has following constructor arguments
public class ...
0
votes
1
answer
355
views
MediatR: Two Handle methods in one QueryHandler class
I use MediatR library in my project. I'm wondeing if it is ok to have two Handle methods in one class? The reason I wanted to do that is that both methods use the shared code which shouldn't be moved ...
2
votes
0
answers
167
views
Problem with implementing FluentValidation with Clean Architecture
I recently started making new app using Clean Architecture + CQRS with MediatR. This is my first attempt to this architecture and I want to implement this architecture without using any templates, ...
0
votes
1
answer
886
views
How to register generic type mediatR handler?
I am trying to use a Generic type mediatR IRequestHandler in my application. But I get an error "No service registered". Here is the sample application to re-create the error.
This is my ...