Blazor JS interop [Bug]
See original GitHub issueDescription
Calling JS from C# in MAUI-Blazor app not work.
Steps to Reproduce
- RCL with JS interop wrapped to C# class
- Call
Expected Behavior
Work same as with browser. With browser same RCL work.
Actual Behavior
Basic Information
- Version with issue:
- Last known good version:
- IDE: VS19.VS22
- Platform Target Frameworks:
- Android: emulator
"Object reference not set to an instance of an object."
at Microsoft.AspNetCore.Components.WebView.Services.WebViewJSRuntime.BeginInvokeJS(Int64 taskId, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId) in Microsoft.AspNetCore.Components.WebView.dll:token 0x6000113+0x0
at Microsoft.JSInterop.JSRuntime.InvokeAsync[IJSObjectReference](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args) in Microsoft.JSInterop.dll:token 0x600003a+0x10a
at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.IJSObjectReference, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() in Microsoft.JSInterop.dll:token 0x60000a8+0xf7
at Obletsvet.Ui.Mobile.Components.SwipeMenu.InitAsync() in C:\Projects\Obletsvet\Obletsvet\src\Obletsvet.Ui.Mobile.Components\SwipeMenu.cs:line 35
at Obletsvet.Ui.Mobile.Components.Shared.TopBar.OnAfterRenderAsync(Boolean firstRender) in C:\Projects\Obletsvet\Obletsvet\src\Obletsvet.Ui.Mobile.Components\Shared\TopBar.razor:line 97
Also notice #1245 and ipcSender
looks like it is also not set in android
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Blazor JS Interop is bugged in an hard to reproduce scenario.
On firefox, my odd setup (vite.js serving blazor and ts files), sometimes trigger an error. While I have not pinpointed the cause, it...
Read more >asp.net core - JavaScript interop Error when calling ...
JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendererd. When prerendering is ...
Read more >ASP.NET Core Blazor JavaScript interoperability (JS interop)
This article explains general concepts on how to interact with JavaScript in Blazor apps. A Blazor app can invoke JavaScript (JS) functions ...
Read more >Error with JS interop in UI for Blazor
I am trying to integrate your blazor components in to my app. I am getting the following error: [2020-08-22T23:29:42.283Z] Error: Microsoft.
Read more >JavaScript Interop Error in Blazor - JSException
Ran across this weird "Unexpected token '?'" error with JavaScript interop in Blazor. The solution was pretty simple, once I figured it out....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If we enable scope validation, error like this will yield much more useful messages. Since we can’t reasonably change the
IJSRuntime
to be registered as a singleton service in MAUI Blazor, let’s use this issue to track enabling scope validation.I think that the JS interop type in your app needs to be registered as Scoped and not Singleton (just like in Blazor Server).
But we should try to make this have a better experience.