entitysignal
entitysignal copied to clipboard
DBcontext error
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: EntitySignal.Services.EntitySignalSubscribe Lifetime: Transient ImplementationType: EntitySignal.Services.EntitySignalSubscribe': Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'EntitySignal.Services.EntitySignalSubscribe'.) Unable to create an object of type 'MyDbContext'.
What version of .net are you using?
While reading the exception it sounds like it is having an issue accessing the httpcontext.
Is this being done in a singleton service?
I know this is quite old but for others still wondering. I had a similar issue and to fix it I added services.AddHttpContextAccessor();
when configuring services and that seemed to have fixed it.
So for example:
private void ConfigureServices(IServiceCollection services)
{
// Other code here ...
services.AddSignalR();
services.AddHttpContextAccessor();
services.AddEntitySignal();
}
Might be worth putting in to the tutorial if I'm correct.
Thank you for the fix @VasilVerdouw :)
I have updated the docs to reflect your change