Electon.Net blazor app not showing window

Viewed 530

I'm trying to use Electron.net for my Blazor project on my Mac.

I'm struggling to get the whole project working properly (I think so). As I found out, when I run

electronize start

The process hangs on listening to ports:

  MyApp -> /Users/...path_to_my_app.../obj/Host/bin/
  node_modules missing in: /Users/...path_to_my_app.../obj/Host/node_modules
  Start npm install...
  removed 1 package, changed 3 packages, and audited 186 packages in 9s
  found 0 vulnerabilities
        ElectronHostHook handling started...
  Invoke electron - in dir: /Users/...path_to_my_app.../obj/Host/node_modules/.bin
  Electron Socket IO Port: 8000
  Electron Socket started on port 8000 at 127.0.0.1
  ASP.NET Core Port: 8001

And it's basically stuck there.

Then when I run

electronize start /watch

all opens just fine (strangely, both the app window as well as Safari open...)

ElectronHostHook handling started...
Invoke electron - in dir: /Users/...PATH.../obj/Host/node_modules/.bin
Electron Socket IO Port: 8000
Electron Socket started on port 8000 at 127.0.0.1
ASP.NET Core Watch Port: 8001
stdout: watch : 
stdout: Started
stdout: Génération...
stdout: Use Electron Port: 8000
stdout: info: Microsoft.Hosting.Lifetime[0]
stdout:       Now listening on: http://localhost:8001
stdout: ASP.NET Core host has fully started.
stdout: info: Microsoft.Hosting.Lifetime[0]
  Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
  Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
  Content root path: /Users/...PATH...
ASP.NET Core Application connected... global.electronsocket J5mifH5-zThaphv4AAAA 2021-03-26T11:46:16.995Z
stdout: BridgeConnector connected!
stdout: warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
  Failed to determine the https port for redirect.

So I suspect my app's setup is somehow corrupt - couldn't find out where though.

Technical specs:

MacOS Big Sur (v11.2.3)
.Net 5.0
Electron v 9.4.4
1 Answers

I ran into the same behavior myself and discovered that it can be caused by your web application throwing a runtime error prior to the call to ElectronNET.API.Electron.WindowManager.CreateWindowAsync in Startup.cs. In my case, the app would build without issue, it was the error early on that caused the launcher to hang without any feedback.

So one solution may be to run dotnet run in the web app directory and make sure you can load the app in a regular browser.

Related