PomeloFoundation / dotNETCore-Extensions

MIT License
182 stars 63 forks source link

.net core 2.0 中 获取不到自己添加的service #19

Closed lentoo closed 6 years ago

lentoo commented 7 years ago

.net core 2.0 在Job的定时调用的方法中通过依赖注入获取不到自己添加的service

yezhaocan commented 6 years ago

同问,怎么解决

miaochongda commented 6 years ago

新建asp.netcore2.0 webapi工程,按照步骤一步步添加,结果是: Unhandled Exception: System.InvalidOperationException: Cannot resolve scoped service 'Pomelo.AspNetCore.TimedJob.IDynamicTimedJobProvider' from root provider. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateResolution(Type serviceType, ServiceProvider serviceProvider) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) at Pomelo.AspNetCore.TimedJob.TimedJobService..ctor(IAssemblyLocator locator, IServiceProvider services) --- End of stack trace from previous location where exception was thrown ---

wjw1-Evan commented 6 years ago

Cannot resolve 'IServices.ISysServices.ISysLogService' from root provider because it requires scoped service 'Microsoft.EntityFrameworkCore.DbContext'.

wjw1-Evan commented 6 years ago

scoped 怎么处理?

yukozh commented 6 years ago

Fixed in 10046

the404 commented 6 years ago

why close,don't give a link

usbook commented 5 years ago

@yezhaocan @lentoo @miaochongda @wjw1-Evan @yukozh how to solve it?did you solve it?