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

[regression/8.0.0-preview.7.8842] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception #16609

Closed
campersau opened this issue Aug 8, 2023 · 22 comments · Fixed by dotnet/aspnetcore#49958
Assignees
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView Blazor ❤️ MAUI Issues in MAUI functionality that affect Blazor, but are not bugs in Blazor itself external i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 t/bug Something isn't working

Comments

@campersau
Copy link
Contributor

campersau commented Aug 8, 2023

Description

When creating a new .NET Maui Blazor App in 8.0.100-preview.7.23376.3 and running it results in the following javascript exception when navigating or clicking on the counter button.

Open the dev tools to see the exception:

blazor.webview.js:1  Uncaught Error: No interop methods are registered for renderer 0
    at k (blazor.webview.js:1:13290)
    at blazor.webview.js:1:13196
    at T (blazor.webview.js:1:13379)
    at N (blazor.webview.js:1:13170)
    at x.dispatchGlobalEventToAllElements (blazor.webview.js:1:15755)
    at x.onGlobalEvent (blazor.webview.js:1:14948)

Steps to Reproduce

  1. Create a new .NET Maui Blazor App and target .NET 8 preview (8.0.100-preview.7.23376.3)
  2. Run the app on e.g. Windows Machine
  3. Open the dev tools
  4. Navigate through the menu and you notice the exception
  5. But its easiest to see on the Counter page and clicking the Click Me button

Link to public reproduction project repository

No response

Version with bug

8.0.100-preview.7.23376.3

Last version that worked well

8.0.0-preview.6.8686

Affected platforms

Windows, and others

Affected platform versions

net8.0-windows10.0.19041.0

Did you find any workaround?

#16609 (comment)

Relevant log output

blazor.webview.js:1  Uncaught Error: No interop methods are registered for renderer 0
    at k (blazor.webview.js:1:13290)
    at blazor.webview.js:1:13196
    at T (blazor.webview.js:1:13379)
    at N (blazor.webview.js:1:13170)
    at x.dispatchGlobalEventToAllElements (blazor.webview.js:1:15755)
    at x.onGlobalEvent (blazor.webview.js:1:14948)
@campersau campersau added the t/bug Something isn't working label Aug 8, 2023
@PureWeen PureWeen added area-blazor Blazor Hybrid / Desktop, BlazorWebView Blazor ❤️ MAUI Issues in MAUI functionality that affect Blazor, but are not bugs in Blazor itself labels Aug 8, 2023
@samhouts samhouts added the i/regression This issue described a confirmed regression on a currently supported version label Aug 8, 2023
@samhouts samhouts changed the title .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception in 8.0.100-preview.7.23376.3 [regression/8.0.100-preview.7.23376.3] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception in 8.0.100-preview.7.23376.3 Aug 8, 2023
@samhouts samhouts changed the title [regression/8.0.100-preview.7.23376.3] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception in 8.0.100-preview.7.23376.3 [regression/8.0.100-preview.7.23376.3] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception Aug 8, 2023
@Eilon Eilon self-assigned this Aug 9, 2023
@Eilon
Copy link
Member

Eilon commented Aug 9, 2023

Alright we think we know what caused this and have a solution we're testing. We'll also test out a workaround so that anyone running into this in .NET 8 Preview 7 can get their Blazor Hybrid apps working.

cc @MackinnonBuck

@Eilon
Copy link
Member

Eilon commented Aug 9, 2023

Note: .NET 8 RC1 is available and does not require any workaround

.NET 8 RC1 blog post is here with download details: https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-rc1/

But if you're still on .NET 8 Preview 7, continue reading for the workaround...

Workaround for .NET 8 Preview 7

For anyone encountering this issue in .NET 8 Preview 7 (released August 8th, 2023), here's how you can work around it in your apps.

Background

A change was made to Blazor in .NET 8 Preview 7 to enable new Blazor Server and WebAssembly rendering scenarios. Unfortunately there is a bug that affects all Blazor Hybrid scenarios (the BlazorWebView control in .NET MAUI, WPF, and WinForms). The bug causes events such as button clicks in the BlazorWebView control to fail.

Workaround steps

  1. Download the file blazor.webview.net8-p7fix.zip, decompress the ZIP, and add the blazor.webview.net8-p7fix.js in it to your app's wwwroot folder
  2. Edit your app's wwwroot/index.html file and change the _framework/blazor.webview.js reference to instead point to the new file you added:
    <script src="blazor.webview.net8-p7fix.js" autostart="false"></script>
    (Note that the exact filename/sub-folder don't matter, so you can rename the file, as long as it doesn't conflict with any other existing file in your app.)
  3. You should now be able to build/run/publish your app on all .NET MAUI platforms

This is already fixed for the next pre-release of .NET 8. When you update to the next pre-release of .NET 8, you will need to delete the file that you added and also change back the <script ...> reference in index.html.

If anyone here tries out this workaround and is successful (or not), please let us know. Thanks!

@Fydar
Copy link

Fydar commented Aug 10, 2023

The workaround was successful for me! Thanks for that! 🎉

@v-Lily
Copy link

v-Lily commented Aug 11, 2023

@Eilon I tried the workaround in #16609 (comment), but it didn't solve my issue(#2270). Detailed reproduction steps refer to issue #2270.

image

@Eilon
Copy link
Member

Eilon commented Aug 11, 2023

@MackinnonBuck - any idea about this one? In the macOS screenshot it's showing renderer 3, which I think is correct (it used to say renderer 0). And the filename shows that it's using the fixed JS file.

@MackinnonBuck
Copy link
Member

I'll need a full repro to know what's going on there. @v-Lily, does your project use preview7 nugets? Could you please upload a repro project as a public GitHub repository?

@Xyncgas
Copy link

Xyncgas commented Aug 14, 2023

Thank u

@v-Lily
Copy link

v-Lily commented Aug 14, 2023

I'll need a full repro to know what's going on there. @v-Lily, does your project use preview7 nugets? Could you please upload a repro project as a public GitHub repository?

@MackinnonBuck
Yes, my project uses preview 7 nugets and this issue also reproduces on Windows. I have uploaded the Windows repro project as a public GitHub repository.

@Eilon
Copy link
Member

Eilon commented Aug 14, 2023

I'll take a look.

@Eilon
Copy link
Member

Eilon commented Aug 14, 2023

I'll need a full repro to know what's going on there. @v-Lily, does your project use preview7 nugets? Could you please upload a repro project as a public GitHub repository?

@MackinnonBuck Yes, my project uses preview 7 nugets and this issue also reproduces on Windows. I have uploaded the Windows repro project as a public GitHub repository.

I cloned the repro and ran it on Windows and it seemed to work fine:

image

But I'll look some more.

@Eilon
Copy link
Member

Eilon commented Aug 14, 2023

Here's the SDK version I'm using:

C:\Users\elipton>dotnet --info
.NET SDK:
 Version:   8.0.100-preview.7.23376.3
 Commit:    daebeea8ea

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.0-preview.7.23375.6
  Architecture: x64
  Commit:       65b696cf5e
  RID:          win-x64

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  7.0.400 [C:\Program Files\dotnet\sdk]
  8.0.100-preview.7.23376.3 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.7.23375.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.4.23259.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.7.23375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.4.23260.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.7.23376.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

@v-Lily - can you run dotnet --info and report what you see?

@Eilon
Copy link
Member

Eilon commented Aug 14, 2023

And in the repro app from @v-Lily if I switch back to the regular blazor.webview.js that has the bug, I get the expected renderer failure.

In index.html I changed it to:

    <script src="/_framework/blazor.webview.js" autostart="false"></script>
    <!-- <script src="blazor.webview.net8-p7fix.js" autostart="false"></script> -->

And here's the 'expected' error on Windows:
image

And Android:
image

@Eilon
Copy link
Member

Eilon commented Aug 14, 2023

@v-Lily - I wonder if maybe the app wasn't fully re-built? Can you try doing a "Clean" and then build/run again?

@v-Lily
Copy link

v-Lily commented Aug 15, 2023

@v-Lily - can you run dotnet --info and report what you see?

@Eilon Thanks for your comment.
Here's the SDK version I'm using:

C:\Users\v-lilyli1>dotnet --info
.NET SDK:
 Version:   8.0.100-preview.7.23376.3
 Commit:    daebeea8ea

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.0-preview.7.23375.6
  Architecture: x64
  Commit:       65b696cf5e
  RID:          win-x64

.NET SDKs installed:
  8.0.100-preview.7.23376.3 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.7.23375.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.7.23375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.7.23376.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

@v-Lily - I wonder if maybe the app wasn't fully re-built? Can you try doing a "Clean" and then build/run again?

I have fully rebuilt the app. The issue still reproduces after I try to do a "clean" and build/run again.

image

This is my repro machine: etvmaamy001 - 10.214.92.132. You have been added as an administrator, hope this helps you.

@PeymanDinani
Copy link

This issue only happens on Visual Studio 17.8.0 Preview 1.0.
I rolled back to Visual Studio 17.7.0 Preview 6.0 and opened the same project and it works just fine.

Any Idea?

@ghost
Copy link

ghost commented Aug 25, 2023

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

@Eilon
Copy link
Member

Eilon commented Aug 25, 2023

This issue only happens on Visual Studio 17.8.0 Preview 1.0. I rolled back to Visual Studio 17.7.0 Preview 6.0 and opened the same project and it works just fine.

Any Idea?

@PeymanDinani - this issues affects .NET 8 Preview 7, which I believe came with Visual Studio 17.8 Preview 1. You can either use the workaround listed above, or go back to using an earlier preview of .NET 8 (such as Preview 6). The full fix will be available in the next pre-release of .NET 8.

@PeymanDinani
Copy link

PeymanDinani commented Aug 25, 2023

This issue only happens on Visual Studio 17.8.0 Preview 1.0. I rolled back to Visual Studio 17.7.0 Preview 6.0 and opened the same project and it works just fine.

Any Idea?

@PeymanDinani - this issues affects .NET 8 Preview 7, which I believe came with Visual Studio 17.8 Preview 1. You can either use the workaround listed above, or go back to using an earlier preview of .NET 8 (such as Preview 6). The full fix will be available in the next pre-release of .NET 8.

Oh ok. I guess I am experiencing a different issue with the same side effect. They closed my post on Microsoft visual studio forums and pointed me here.

My issue for reference:

https://developercommunity.visualstudio.com/t/Net-Maui-Blazor-hybrid-app-Events-are-n/10445068

@Eilon
Copy link
Member

Eilon commented Aug 25, 2023

Hi @PeymanDinani , I was the one who closed that issue because it appears to be the same thing (clicks not responding in Blazor Hybrid apps with .NET 8 Preview 7). If you want to use .NET 8 Preview 7, please refer to the workaround listed above (it should only take 2 minutes to do the workaround).

@Xyncgas
Copy link

Xyncgas commented Aug 25, 2023

So if .NET preview becomes stable how do I upgrade my application to it, do I have to create a new project in the newest .NET stable or I can simply update my visual studio + remove the 'temporary changes' we applied using your zip

@Eilon
Copy link
Member

Eilon commented Aug 25, 2023

So if .NET preview becomes stable how do I upgrade my application to it, do I have to create a new project in the newest .NET stable or I can simply update my visual studio + remove the 'temporary changes' we applied using your zip

@Xyncgas - for anyone using specifically .NET 8 Preview 7, you can use the workaround posted above. All other versions are fine (.NET 6, .NET 7, .NET 8 Preview 1-6, and any .NET 8 pre-release after Preview 7).

@Eilon
Copy link
Member

Eilon commented Sep 14, 2023

Hi everyone, you should be able to download .NET 8 RC1 that was released this week and has the official fix. If you previously used the workaround posted above, you'll need to undo that change (delete the JS file and change the <script> reference back).

.NET 8 RC1 blog post is here with download details: https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-rc1/

@samhouts samhouts changed the title [regression/8.0.100-preview.7.23376.3] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception [regression/8.0.0-preview.7.8842] .NET Maui Blazor App throws "No interop methods are registered for renderer" javascript exception Sep 18, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView Blazor ❤️ MAUI Issues in MAUI functionality that affect Blazor, but are not bugs in Blazor itself external i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants