Error on startup
jbonnett92 opened this issue · comments
Hi,
Whilst trying to use your package I get this error on a Blazor Server app:
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BlazorCurrentDevice.IBlazorCurrentDeviceService Lifetime: Singleton ImplementationType: BlazorCurrentDevice.BlazorCurrentDeviceService': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'BlazorCurrentDevice.IBlazorCurrentDeviceService'.)
---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: BlazorCurrentDevice.IBlazorCurrentDeviceService Lifetime: Singleton ImplementationType: BlazorCurrentDevice.BlazorCurrentDeviceService': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'BlazorCurrentDevice.IBlazorCurrentDeviceService'.
---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'BlazorCurrentDevice.IBlazorCurrentDeviceService'.
It compiles on the Maui Blazor Hybrid app, though crashes the app when I assess pages where I use it, but other pages that don't the styles are all over the place.
Any ideas? Just a little informmation that may be relevent is that I am running seperate projects for the views.
the issue was that it was placed as Singleton
and not as Scoped
, i fixed it in my PR
I will take a look soon, I have been off for a while
I will take a look soon, I have been off for a while
It would be great if you could merge in the PR for this and create a new NuGet package. I've tested the branch and it works well.
@jbonnett92 Sorry for the really really late ping but I added where to find an upgraded package in the comment here #6 (comment)
https://github.com/HugoVG/CurrentDevice