其他分享
首页 > 其他分享> > 依赖注入时出错:Cannot consume scoped service 'xxx' from singleton 'yyy'

依赖注入时出错:Cannot consume scoped service 'xxx' from singleton 'yyy'

作者:互联网

错误:

System.AggregateException:“Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: WebApplication9.Models.BgServerTest': Cannot consume scoped service 'WebApplication9.Models.Imywork' from singleton 'Microsoft.Extensions.Hosting.IHostedService'.)”

InvalidOperationException: Cannot consume scoped service 'WebApplication9.Models.Imywork' from singleton 'Microsoft.Extensions.Hosting.IHostedService'.

 

解决办法 :

 

标签:singleton,consume,service,Models,Cannot,IHostedService
来源: https://www.cnblogs.com/lunawzh/p/15110389.html