tresoneur / SpotifyService

A Razor Class Library providing access to Spotify APIs for Blazor WebAssembly apps.
GNU Affero General Public License v3.0
20 stars 3 forks source link

Could not find 'BlazorExtensions.Storage.GetItem' ('BlazorExtensions' was undefined). #6

Closed rhiskey closed 3 years ago

rhiskey commented 3 years ago

Added class library to my Blazor Web-Assembly solution (.net 5.0) and get this error when loading first page:

Microsoft.JSInterop.JSException: Could not find 'BlazorExtensions.Storage.GetItem' ('BlazorExtensions' was undefined).
Error: Could not find 'BlazorExtensions.Storage.GetItem' ('BlazorExtensions' was undefined).
    at http://localhost:52602/_framework/blazor.webassembly.js:1:1287
    at Array.forEach (<anonymous>)
    at e.findFunction (http://localhost:52602/_framework/blazor.webassembly.js:1:1247)
    at b (http://localhost:52602/_framework/blazor.webassembly.js:1:2989)
    at http://localhost:52602/_framework/blazor.webassembly.js:1:3935
    at new Promise (<anonymous>)
    at Object.beginInvokeJSFromDotNet (http://localhost:52602/_framework/blazor.webassembly.js:1:3908)
    at Object.w [as invokeJSFromDotNet] (http://localhost:52602/_framework/blazor.webassembly.js:1:64232)
    at _mono_wasm_invoke_js_blazor (http://localhost:52602/_framework/dotnet.5.0.5.js:1:190800)
    at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__15`1[[Caerostris.Services.Spotify.Auth.Models.AuthToken, Caerostris.Services.Spotify, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Caerostris.Services.Spotify.Auth.Abstract.AuthManagerBase.GetToken() in ~\SpotifyService\Services\Spotify\Auth\Abstract\AuthManagerBase.cs:line 76
   at Caerostris.Services.Spotify.Sections.AuthorizationService.GetAuthToken() in ~\SpotifyService\Services\Spotify\Sections\AuthorizationService.cs:line 120
   at Caerostris.Services.Spotify.Sections.AuthorizationService.IsValidAuthTokenPresent() in ~\SpotifyService\Services\Spotify\Sections\AuthorizationService.cs:line 126
   at Caerostris.Services.Spotify.Sections.AuthorizationService.HandleAuthStatePotentiallyChanged() in ~\SpotifyService\Services\Spotify\Sections\AuthorizationService.cs:line 106
   at Caerostris.Services.Spotify.Sections.AuthorizationService.Initialize() in ~\SpotifyService\Services\Spotify\Sections\AuthorizationService.cs:line 49
   at Caerostris.Services.Spotify.SpotifyService.Initialize() in ~\SpotifyService\Services\Spotify\SpotifyService.cs:line 39
   at Caerostris.Services.Spotify.ServiceCollectionExtensions.InitializeSpotify(IServiceProvider host) in ~\SpotifyService\Services\Spotify\ServiceCollectionExtensions.cs:line 94
   at HVMDash.Client.Program.Main(String[] args) in ~\Client\Program.cs:line 58
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.EntrypointInvoker.InvokeEntrypoint(String assemblyName, String[] args)
tresoneur commented 3 years ago

So the problem here is that the JavaScript utilities of the BlazorExtensions.Storage library are not available in the JavaScript execution context.

Have you added the references listed under the 3rd item of the 'How to use' section of the readme to your index.html, specifically the blazor.extensions.storage.js reference?

<script src="_content/Caerostris.Services.Spotify/blazor.extensions.storage.js"></script>

If so, is the resource available at https://localhost:<port>/_content/Caerostris.Services.Spotify/blazor.extensions.storage.js? Does the network request succeed when your app is loading?

If all of the above questions can be answered with a clear 'yes', then I'll need access to the source code of your solution so that I can reproduce the issue locally.

Thank you for reporting the issue.

rhiskey commented 3 years ago

So the problem here is that the JavaScript utilities of the BlazorExtensions.Storage library are not available in the JavaScript execution context.

Have you added the references listed under the 3rd item of the 'How to use' section of the readme to your index.html, specifically the blazor.extensions.storage.js reference?

<script src="_content/Caerostris.Services.Spotify/blazor.extensions.storage.js"></script>

If so, is the resource available at https://localhost:<port>/_content/Caerostris.Services.Spotify/blazor.extensions.storage.js? Does the network request succeed when your app is loading?

If all of the above questions can be answered with a clear 'yes', then I'll need access to the source code of your solution so that I can reproduce the issue locally.

Thank you for reporting the issue.

So the problem here is that the JavaScript utilities of the BlazorExtensions.Storage library are not available in the JavaScript execution context.

Have you added the references listed under the 3rd item of the 'How to use' section of the readme to your index.html, specifically the blazor.extensions.storage.js reference?

<script src="_content/Caerostris.Services.Spotify/blazor.extensions.storage.js"></script>

If so, is the resource available at https://localhost:<port>/_content/Caerostris.Services.Spotify/blazor.extensions.storage.js? Does the network request succeed when your app is loading?

If all of the above questions can be answered with a clear 'yes', then I'll need access to the source code of your solution so that I can reproduce the issue locally.

Thank you for reporting the issue.

Yes, resourse is avalible image

Reopened my solution at different machine, edit <TargetFramework>net5.0</TargetFramework> and issue has gone away.