Reshiru / Blazor.IndexedDB.Framework

A framework for blazor which acts as an interface to IndexedDB
MIT License
77 stars 27 forks source link

Cannot consume scoped service #11

Open dmarciano opened 5 years ago

dmarciano commented 5 years ago

I installed the NuGet package and followed the code samples provided, but when I attempted to run the site I get the following error message:

InvalidOperationException: Error while validating the service descriptor 'ServiceType: Blazor.IndexedDB.Framework.IIndexedDbFactory Lifetime: Singleton ImplementationType: Blazor.IndexedDB.Framework.IndexedDbFactory': Cannot consume scoped service 'Microsoft.JSInterop.IJSRuntime' from singleton 'Blazor.IndexedDB.Framework.IIndexedDbFactory'.

In the Startup.cs file, if I add the library as a transient (i.e. services.AddTransient<IIndexedDbFactory, IndexedDbFactory>();) then my site will load but when I try to call the create method I get an error about TimeGhost not being found in the window. I tried searching online for anything about TimeGhost but had no luck.

dmarciano commented 5 years ago

So after a lot of trial and error I was finally able to get this to work. It required me to do three things:

  1. Add the indexedDb.Blazor.js file to my project and include it in my _Host.cshtml file using a Githubissues.
  2. Githubissues is a development platform for aggregating issues.