Skip to content
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

Problem with load web #23

Open
domizacz opened this issue Oct 19, 2020 · 2 comments
Open

Problem with load web #23

domizacz opened this issue Oct 19, 2020 · 2 comments

Comments

@domizacz
Copy link

I have a problem with the all versions .
error is
`
System.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'.)'

System.AggregateException
HResult=0x80131500
Message=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'.)
Source=Microsoft.Extensions.DependencyInjection
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter1.CreateServiceProvider(Object containerBuilder)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at TestDelete.Program.Main(String[] args) in C:\Users\Dom\source\repos\TestDelete\TestDelete\Program.cs:line 18

This exception was originally thrown at this call stack:
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.CallSiteValidatorState)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, TArgument)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.CallSiteValidatorState)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSiteMain(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, TArgument)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitRootCache(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.CallSiteValidatorState)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite, TArgument)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite)
Microsoft.Extensions.DependencyInjection.ServiceProvider.Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceProviderEngineCallback.OnCreate(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite)
Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.ValidateService(Microsoft.Extensions.DependencyInjection.ServiceDescriptor)

Inner Exception 1:
InvalidOperationException: 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'.

Inner Exception 2:
InvalidOperationException: Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'AspNetMonsters.Blazor.Geolocation.LocationService'.
`

@gabrieldelaparra
Copy link

Replace services.AddSingleton<LocationService> with services.AddScoped<LocationService>

@djaus2
Copy link

djaus2 commented Jan 2, 2021

This issue can be closed. That is the solution along with the need for location.js. as covered elsewhere.
I have proposed an updated which covers this.

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

3 participants