Storage icon indicating copy to clipboard operation
Storage copied to clipboard

Could not find 'BlazorExtensions' in 'window' (*Client* mode)

Open AndreasGaus opened this issue 4 years ago • 13 comments

BlazorExtensions/Storage 1.1.0-preview3 issue:

Similar to issue #35 "Could not find 'BlazorExtensions' in 'window' (Server mode)", but client side:

After updating from ASP .NET 3.0 to latest 3.1 Microsoft.AspNetCore.Blazor (3.1.0-preview4.19579.2), I had to change the injection to the related interfaces to compile:

using Blazor.Extensions.Storage; using Blazor.Extensions.Storage.Interfaces;

The first "using" statement seems not necessary any more.

And injection also changed from the class "SessionStorage" to the new interface style "ISessionStorage": [Inject] protected ISessionStorage SessionStorage { get; set; }

But after compiling successfully, I also receive the following exception (similar to server side issue):

WASM: Microsoft.JSInterop.JSException: Could not find 'BlazorExtensions' in 'window'. blazor.webassembly.js:1:35158 printErr http://localhost:58811/_framework/blazor.webassembly.js:1 put_char http://localhost:58811/_framework/wasm/mono.js:1 write http://localhost:58811/_framework/wasm/mono.js:1 write http://localhost:58811/_framework/wasm/mono.js:1 doWritev http://localhost:58811/_framework/wasm/mono.js:1 _fd_write http://localhost:58811/_framework/wasm/mono.js:1 http://localhost:58811/_framework/wasm/mono.wasm:400200 http://localhost:58811/_framework/wasm/mono.wasm:403904 http://localhost:58811/_framework/wasm/mono.wasm:17263 http://localhost:58811/_framework/wasm/mono.wasm:190639 http://localhost:58811/_framework/wasm/mono.wasm:739184 http://localhost:58811/_framework/wasm/mono.wasm:148347 http://localhost:58811/_framework/wasm/mono.wasm:500900 http://localhost:58811/_framework/wasm/mono.wasm:501148 http://localhost:58811/_framework/wasm/mono.wasm:330473 http://localhost:58811/_framework/wasm/mono.wasm:477291 http://localhost:58811/_framework/wasm/mono.wasm:893930 http://localhost:58811/_framework/wasm/mono.wasm:895281 http://localhost:58811/_framework/wasm/mono.wasm:751234 _mono_background_exec http://localhost:58811/_framework/wasm/mono.js:1 pump_message http://localhost:58811/_framework/wasm/mono.js:1

What is the reasons for this? It seems as if the client side can not access the BlazorExtensions out of the box any more (which worked fine using .NET Core 3.0 and Blazor.Extensions.Storage 1.0).

AndreasGaus avatar Dec 10 '19 14:12 AndreasGaus

Same error, but using SignalR extension.

abbatepabloo avatar Dec 14 '19 13:12 abbatepabloo

I just hit this error as well 2 days ago. I updated the package now is not working anymore.

arivera12 avatar Dec 15 '19 18:12 arivera12

In the meantime I downgrade the package to version 0.4.0 until this gets fixed.

arivera12 avatar Dec 15 '19 18:12 arivera12

Have mine working on 3.1 latest preview both client-side Blazor and server-side Blazor work for me. The error message indicates that the javascript required is either not found at the required path or not loaded. Had to go through these little hoops till this gets fixed: https://github.com/BlazorExtensions/Storage/issues/35#issuecomment-554121492

rovercoder avatar Dec 16 '19 19:12 rovercoder

Yes, the workaround presented by @rovercoder also worked for me: https://github.com/BlazorExtensions/Storage/issues/35#issuecomment-554121492

However, the blazor.extensions.storage.js file (see attachment below) must be always copied to the client's

\bin\Debug\netstandard2.1\dist\_content

folder which is not stored in git by default.

May I ask for a solution and when a new fixed release will be available? Thanks in advance!

Workaround by copying manually this file to \bin\Debug\netstandard2.1\dist_content: blazor.extensions.storage.js.zip <<<

AndreasGaus avatar Jan 09 '20 13:01 AndreasGaus

Folks sorry for the delay.

I'm working on a way to make the process of reference the static content (CSS/JS) to the target project the way it expects.

It is important to know that Blazor broke every single component when they removed the ability to add the static content using the resources. Now I'm looking for a way to make this happen properly.

I can't stand off and ask every developer to manually add entries for the static content on their projects as this break the very nature of Nuget and packages. That is the reason I didn't updated all the packages yet as it is pointless.

I'll come out with a proper solution relatively soon. I'll open an issue on the Home repo of this org to let everyone know.

Thanks!

galvesribeiro avatar Jan 09 '20 13:01 galvesribeiro

Any news on these topics?

AndreasGaus avatar Jan 16 '20 09:01 AndreasGaus

I just installed the Blazor.Extensions.Storage 1.0.0 package on my Client Blazor Project and I am getting the exception: Microsoft.JSInterop.JSException: Could not find 'Storage' in 'window.BlazorExtensions'.

I added the line below in my index.html and I get a 404 resource not found Error.

Is there any way to fix this problem? I also tried installing the latest Preview version of the package and it has the same problem.

char8cter avatar May 06 '20 19:05 char8cter

Yes, the workaround presented by @rovercoder also worked for me: #35 (comment)

However, the blazor.extensions.storage.js file (see attachment below) must be always copied to the client's

\bin\Debug\netstandard2.1\dist\_content

folder which is not stored in git by default.

May I ask for a solution and when a new fixed release will be available? Thanks in advance!

Workaround by copying manually this file to \bin\Debug\netstandard2.1\dist_content: blazor.extensions.storage.js.zip <<<

@char8cter download this zip a manual reference it.

arivera12 avatar May 08 '20 02:05 arivera12

with .net core 3.1 last solution did not working (((

yoosYyd avatar May 08 '20 08:05 yoosYyd

I also jumped to the Blazor web assembly RC and got this exception. Is there a way to solve it rather than copying files? as a client of tis nuget library, I can't find that file at all...

meirkr avatar May 17 '20 00:05 meirkr

I have the same issue for v 1.1.0-preview3 _content/Blazor.Extensions.Storage/Storage.js is not available

MichaelSL avatar May 28 '20 12:05 MichaelSL

I have found that too much time have past without fixing this simple bug. I cloned and improved this code removing all JavaScript dependencies please follow my repo and package BlazorBrowserStorage

arivera12 avatar May 28 '20 17:05 arivera12