【发布时间】:2022-04-13 21:02:53
【问题描述】:
当我将 IMapper 注入 MediatR 命令处理程序时出现此问题。我在此之前正确注入,但之后更改了 AutoMapper 和 MediatR 配置,如下所示。 (我添加了所有应用层的程序集)
services.AddAutoMapper(Assembly.GetExecutingAssembly(),
typeof(CreateAccountCommand).Assembly,
typeof(EfRepository<,>).Assembly,
typeof(IRepository<,>).Assembly,
typeof(KeyValueDto).Assembly);
services.AddMediatR(Assembly.GetExecutingAssembly(),
typeof(CreateAccountCommand).Assembly,
typeof(EfRepository<,>).Assembly,
typeof(IRepository<,>).Assembly,
typeof(KeyValueDto).Assembly);
当我执行 CreateAccountCommand 时出现如下错误:
Error constructing handler for request of type MediatR.IRequestHandler`2[Application.Actions.Users.Commands.CreateAccountCommand,Application.Common.Models.GenericResponse`1[System.String]]. Register your handlers with the container. See the samples in GitHub for examples.
内部异常如下
Property 'System.Linq.IQueryable`1[Domain.Entities.Thumbnail] Thumbnails' is not defined for type 'Domain.Entities.Thumbnail' (Parameter 'property')
【问题讨论】:
-
您运行的程序集版本似乎与您构建和测试的程序集不同。你需要让它们同步。
标签: c# asp.net-core automapper mediatr