Struggling with DI in a worker project #3071
-
I've been able to get a new Blazor application setup and using Csla 6.x. I've struggled the past several days getting a worker process to work. I don't know what I'm doing, so it's probably something simple. Any help would be greatly appreciated. When I run the worker, I get the following error in program.cs. It occures for the IHost host = block of code. "System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.Extensions.Hosting.IHostedService Lifetime: Singleton ImplementationType: BlazorApp.Worker.Worker': Cannot consume scoped service 'Csla.ApplicationContext' from singleton 'Microsoft.Extensions.Hosting.IHostedService'.)'" Thank you any help! Program.cs looks like
Worker.cs looks like
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Changing Worker.cs to this works. Seems cheesy, though. DI passes in IServiceProvider, I CreateScope() and grab the ServiceProvider off of it. THEN I can use the dataportal. meh.
|
Beta Was this translation helpful? Give feedback.
Changing Worker.cs to this works. Seems cheesy, though. DI passes in IServiceProvider, I CreateScope() and grab the ServiceProvider off of it. THEN I can use the dataportal.
meh.