Skip to content

Error when adding LocationService as singleton #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreas-nesheim opened this issue Sep 29, 2019 · 1 comment
Closed

Error when adding LocationService as singleton #11

andreas-nesheim opened this issue Sep 29, 2019 · 1 comment

Comments

@andreas-nesheim
Copy link

Hi,

I am trying to use this with the official Blazor release, but I get an error when following the example. Especially with this line:
services.AddSingleton<LocationService>();

I get the following error when starting it up:
AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: AspNetMonsters.Blazor.Geolocation.LocationService Lifetime: Singleton ImplementationType: AspNetMonsters.Blazor.Geolocation.LocationService': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'AspNetMonsters.Blazor.Geolocation.LocationService'.) Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable<ServiceDescriptor> serviceDescriptors, ServiceProviderOptions options)

I tried changing the AddSingleton() to a AddScoped(), but then I got another run-time error.

Let me know if you need some logs or anything else from me.

@andreas-nesheim
Copy link
Author

Closed as PR #12 solved the issues for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant