question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrading Blazor WebAssembly to 3.1.0-preview4.19579.2 leads to an error: Could not find 'BlazorExtensions' in 'window'.

See original GitHub issue

Recently 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 in test\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 exists
  • test\Blazor.Extensions.SignalR.Test.Client\bin\Debug\netstandard2.1\dist\_framework\blazor.boot.json 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
galvesribeirocommented, Jan 29, 2020

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

2reactions
szmaleccommented, Jan 29, 2020

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find property of window when doing JS interop ...
I have initially tried using the JSRuntime.Current.InvokeAsync right in my cshtml file and this error with window appeared.When i am delegating ...
Read more >
blazor - Could not find 'BlazorInputFile' in 'window'
If that doesn't work, I have a Nuget project with a working sample project that uses a wrapper to Steve Sanderson Blazor File...
Read more >
Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
Host and deploy ASP.NET Core Blazor WebAssembly
This strategy is covered in the Hosted deployment with ASP.NET Core section. The Blazor app is placed on a static hosting web server...
Read more >
JavaScript Errors - Telerik UI for Blazor - Documentation
JavaScript Errors. This page provides solutions for JavaScript errors that you may encounter while working with Telerik UI for Blazor components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found