entitysignal icon indicating copy to clipboard operation
entitysignal copied to clipboard

DBcontext error

Open stoppiNeobiz opened this issue 3 years ago • 2 comments

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'.

stoppiNeobiz avatar Apr 11 '21 05:04 stoppiNeobiz

What version of .net are you using?

dustout avatar Apr 11 '21 15:04 dustout

While reading the exception it sounds like it is having an issue accessing the httpcontext.

Is this being done in a singleton service?

dustout avatar Apr 11 '21 15:04 dustout

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.

VasilVerdouw avatar Apr 21 '23 13:04 VasilVerdouw

Thank you for the fix @VasilVerdouw :)

I have updated the docs to reflect your change

dustout avatar May 17 '23 01:05 dustout