Hi,
I have this background job that inherits from AsyncBackgroundJob, ITransientDependency
public class PrepareInvoiceEnvelopeJob : AsyncBackgroundJob<long>, ITransientDependency
And i have a private app configurator that i am trying to inject.
private readonly IConfigurationRoot _appConfiguration;
But i get the following error:
Abp.BackgroundJobs.BackgroundJobManager - Castle.MicroKernel.Handlers.HandlerException: Can't create component 'uenlkr4e.Portal.PrepareInvoiceEnvelopeJob' as it has dependencies to be satisfied. 'uenlkr4e.Portal.PrepareInvoiceEnvelopeJob' is waiting for the following dependencies:
- Service 'Microsoft.Extensions.Configuration.IConfigurationRoot' which was not registered.
What am i missing here? thanks in advance.
2 Answer(s)
-
0
Hi uenlkr4e
You should use IConfiguration instead of IConfigurationRoot since the DI system provides IConfiguration by default. If you still want to use IConfigurationRoot, it is more appropriate to use it with IAppConfigurationAccessor. This interface has also been replaced in the module. You can refer to the sample code below.
public class PrepareInvoiceEnvelopeJob : AsyncBackgroundJob<long>, ITransientDependency { private readonly IConfigurationRoot _appConfiguration; public PrepareInvoiceEnvelopeJob(IAppConfigurationAccessor appConfigurationAccessor) { _appConfiguration = appConfigurationAccessor.Configuration; } }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thank you, I will give it a try.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)