Upgrading Blazor WebAssembly to 3.1.0-preview4.19579.2 leads to an error: Could not find 'BlazorExtensions' in 'window'.
See original GitHub issueRecently I tried to update my blazor wasm project (which uses Blazor.Extensions.SignalR v1.1.0-preview3
) to latest 3.1.0-preview4.19579.2
Blazor version.
After updating, an error began to appear in browser console:
Could not find 'BlazorExtensions' in 'window'. Error: Could not find 'BlazorExtensions' in 'window'.
at http://localhost:7258/_framework/blazor.webassembly.js:1:8937
at Array.forEach (<anonymous>)
at p (http://localhost:7258/_framework/blazor.webassembly.js:1:8898)
at Object.invokeJSFromDotNet (http://localhost:7258/_framework/blazor.webassembly.js:1:9470)
at _mono_wasm_invoke_js_marshalled (http://localhost:7258/_framework/wasm/mono.js:1:165750)
at wasm-function[6221]:0x11936a
at wasm-function[1431]:0x402ee
at wasm-function[636]:0x147cf
at wasm-function[636]:0x19ae2
at wasm-function[4996]:0xeb135
It is probably due to latest changes related to static assets in libraries - as we can see at https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-core-3-1/
Support for static assets in libraries when publishing
Standalone Blazor WebAssembly apps now support static assets from Razor class libraries both during development and when publishing. This applies to both standalone Blazor WebAssembly apps and ASP.NET Core hosted apps. Static assets are consumed from referenced libraries using the path prefix: _content/{LIBRARY NAME}/.
There is also PR @ AspNetCore src repo: https://github.com/aspnet/AspNetCore/pull/17353/files Problem is also reported in several other projects which uses *.js static assets.
Initially I have also tried to update Blazor.Extensions.SignalR
to 3.1.0-preview4.19579.2
and the same Could not find 'BlazorExtensions' in 'window'
occured when Blazor.Extensions.SignalR.Test.Server
started.
I have discovered some differences between old build output and new build output, eg.:
[old - netstandard2.0]
- there WAS:
test\Blazor.Extensions.SignalR.Test.Client\bin\Debug\netstandard2.0\dist\_content\Blazor.Extensions.SignalR.JS
- there WAS:
"jsReferences": [ "_content/Blazor.Extensions.SignalR.JS" ]
entry intest\Blazor.Extensions.SignalR.Test.Client\bin\Debug\netstandard2.0\dist\_framework\blazor.boot.json
[new - netstandard2.1]
test\Blazor.Extensions.SignalR.Test.Client\bin\Debug\netstandard2.1\dist\_content\Blazor.Extensions.SignalR.JS
does NOT existstest\Blazor.Extensions.SignalR.Test.Client\bin\Debug\netstandard2.1\dist\_framework\blazor.boot.js
on does NOT contain"jsReferences": [ "_content/Blazor.Extensions.SignalR.JS" ]
entry
I have forked Blazor.Extensions.SignalR
repo and I will try to prepare workaround…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:10 (1 by maintainers)
Top GitHub Comments
@szmalec Yes, the SignalR client is now supported on WebAssembly as expected.
One quick note… Before you blame “Blazor Extensions SignalR problems”, please read the real reason why it has problems before start attacking others.
For future readers, the problem is caused because Blazor changed the way it deals with static content (CSS/JS) and that breaks every single extension out there making components useless.
As stated here we are working on bring a solution for this issue that doesn’t requires manual interaction with JS/CSS files by the final user otherwise, it will not make any sense at all. It beats the purpose of a NuGet package in its essence.
It looks that we can now forget about problems with Blazor Extensions SignalR and use Microsoft.AspNetCore.SignalR.Client directly - see “Support for the .NET SignalR client” section @ https://devblogs.microsoft.com/aspnet/blazor-webassembly-3-2-0-preview-1-release-now-available/