Добавление сервиса в фоновую задачу
Реализую старт фоновой задачи по примеру
В классе TimedHostedService : IHostedService, IDisposable мне необходимо добавить еще доп сервис с реализацией нескольких методов из другого проекта
public class SchedulerSettings : IHostedService, IDisposable
{
protected readonly IProxyService _proxyService;
public SchedulerSettings(IProxyService proxyService)
{
_proxyService = proxyService;
}
public Task StartAsync(CancellationToken cancellationToken)
{
var a = _proxyService.GetListProxyIp();
throw new NotImplementedException();
}
Но при загрузке Program.cs падает ошибка
System.AggregateException: "Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: Web.Settings.Scheduler.SchedulerSettings': Unable to resolve service for type 'ApplicationCore.Interfaces.Services.IProxyService' while attempting to activate 'Web.Settings.Scheduler.SchedulerSettings'.)"
Как правильно реализовать запуск фоновой задачи при старте asp.net приложения?