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

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

Open
AndreasGaus opened this issue Dec 10, 2019 · 13 comments
Open

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

AndreasGaus opened this issue Dec 10, 2019 · 13 comments

Comments

@AndreasGaus
Copy link

AndreasGaus commented Dec 10, 2019

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).

@abbatepabloo
Copy link

Same error, but using SignalR extension.

@arivera12
Copy link

arivera12 commented Dec 15, 2019

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

@arivera12
Copy link

arivera12 commented Dec 15, 2019

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

@rovercoder
Copy link

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:
#35 (comment)

@AndreasGaus
Copy link
Author

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
<<<

@galvesribeiro
Copy link
Member

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!

@AndreasGaus
Copy link
Author

Any news on these topics?

@sauropsid
Copy link

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.

<script src="_content/Blazor.Extensions.Storage/Storage.js"></script>

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.

@arivera12
Copy link

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.

@yoosYyd
Copy link

yoosYyd commented May 8, 2020

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

@meirkr
Copy link

meirkr commented May 17, 2020

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...

@MichaelSL
Copy link

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

@arivera12
Copy link

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

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

9 participants