我有一个最初用.Netcore 3.1编写的项目。我正在将这个项目迁移到.Net6.0。
我过去常常用生命时间( Lifetime:瞬态)来注入/注册MediatR ServiceFactory。
services.AddTransient<ServiceFactory, ServiceFactory>();但是,当我迁移到.Net6.0时,我发现了一个错误:
InvalidOperationException: Error while validating the service descriptor 'ServiceType: MediatR.ServiceFactory Lifetime: Transient ImplementationType: MediatR.ServiceFactory': Unable to resolve service for type 'System.Object' while attempting to activate 'MediatR.ServiceFactory'.
我想知道如何在MediatR ServiceFactory中注入/注册.Net6.0?
发布于 2022-10-07 16:48:17
我们不需要将MediatR服务工厂注册为单独的东西。AddMediatR扩展应该处理这个问题。
https://stackoverflow.com/questions/73988529
复制相似问题