When the application starts the error occurs
The constructor of type ImportExportController contains the parameter
with name 'serviceProvider' and type IServiceProvider that is not
registered. Please ensure IServiceProvider is registered, or change
the constructor of ImportExportController
My code
public class ImportExportController : BaseController
{
private readonly IServiceProvider _serviceProvider;
public ImportExportController(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
}
for the injection of dependencies I'm using the Simple Injector
The error happens in the container.Verify();
private static void Register(Container container)
{
_container = container;
container.Register<IXmlServices, XmlServices>();
container.Verify();
}
I'm using _serviceProvider here
foreach (var element in productsToImport)
{???????
using (var scope = _serviceProvider.CreateScope())
{???????
var app = scope.ServiceProvider.GetService<IImportApp>();
var task = Task.Run(() => app.ImportData(element, UserName, ImportID, PricesCurrencies));
listTask.Add(task);
}???????
}???????
Task.WaitAll(listTask.ToArray());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…