Not work with .net 8.0 blazor web project #1006

Closed
opened 2026-01-29 16:54:25 +00:00 by claunia · 3 comments
Owner

Originally created by @mafei1982 on GitHub (Nov 14, 2025).

  • Version:
    0.1.0
  • Target:

Steps to Reproduce:

  1. Just create a blazor web project (.net 8+) with sample weather code. And follow your instructions to enable electronnet
Image
  1. press F5, and open dev tools and you will see:
Image The blazor related js cannot work properly
Originally created by @mafei1982 on GitHub (Nov 14, 2025). <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: 0.1.0 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> <!-- What target are you building for? --> * **Target**: <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> Steps to Reproduce: 1. Just create a blazor web project (.net 8+) with sample weather code. And follow your instructions to enable electronnet <img width="607" height="615" alt="Image" src="https://github.com/user-attachments/assets/3d129bf1-6bc3-4986-9e12-43fba4317887" /> 2. press F5, and open dev tools and you will see: <img width="1174" height="334" alt="Image" src="https://github.com/user-attachments/assets/868fd91a-99a0-4e13-a4d4-6f1d18a1de49" /> The blazor related js cannot work properly
claunia added the bugdocumentationapplications labels 2026-01-29 16:54:25 +00:00
Author
Owner

@FlorianRappl commented on GitHub (Nov 14, 2025):

I got it working pretty much out of the box. There is just two things:

  1. See #823 - you'll need to "tell" Blazor it's still in a browser. As the heuristic is pretty bad, it thinks its running in Node.js.
  2. The HMR does not work with a weird message that jQuery is not loaded - my best guess is that VS does not inject the required code.

I think we can improve (1) to the point that there is a property "AllowBlazor" or "IsBlazorProcess" (or similar). When this property is set we introduce a preload script that will set process to undefined, leading to Blazor as it should.

For (2) I am still looking why exactly we run into this and what we can do to improve it. Will be also coming in.

@FlorianRappl commented on GitHub (Nov 14, 2025): I got it working pretty much out of the box. There is just two things: 1. See #823 - you'll need to "tell" Blazor it's still in a browser. As the heuristic is pretty bad, it thinks its running in Node.js. 2. The HMR does not work with a weird message that jQuery is not loaded - my best guess is that VS does not inject the required code. I think we can improve (1) to the point that there is a property "AllowBlazor" or "IsBlazorProcess" (or similar). When this property is set we introduce a preload script that will set `process` to `undefined`, leading to Blazor as it should. For (2) I am still looking why exactly we run into this and what we can do to improve it. Will be also coming in.
Author
Owner

@FlorianRappl commented on GitHub (Nov 14, 2025):

Yeah I can make (2) also work like (1) - reason was that jQuery (which is part of browserLink) has a check to detect if its running in a CJS system. As module is also defined by Electron this was not working. Essentially same fix -> global.process = undefined; global.module = undefined.

@FlorianRappl commented on GitHub (Nov 14, 2025): Yeah I can make (2) also work like (1) - reason was that jQuery (which is part of `browserLink`) has a check to detect if its running in a CJS system. As `module` is also defined by Electron this was not working. Essentially same fix -> `global.process = undefined; global.module = undefined`.
Author
Owner

@FlorianRappl commented on GitHub (Nov 14, 2025):

Rolled out 0.2.0-pre.200:

builder.UseElectron(args, async () =>
{
    var browserWindow = await Electron.WindowManager.CreateWindowAsync(
        new BrowserWindowOptions { Show = false, AutoHideMenuBar = true, IsRunningBlazor = false });

    browserWindow.OnReadyToShow += () => browserWindow.Show();
});

Release ETA is Monday.

@FlorianRappl commented on GitHub (Nov 14, 2025): Rolled out [0.2.0-pre.200](https://www.nuget.org/packages/ElectronNET.Core/0.2.0-pre.200#readme-body-tab): ```cs builder.UseElectron(args, async () => { var browserWindow = await Electron.WindowManager.CreateWindowAsync( new BrowserWindowOptions { Show = false, AutoHideMenuBar = true, IsRunningBlazor = false }); browserWindow.OnReadyToShow += () => browserWindow.Show(); }); ``` Release ETA is Monday.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1006