Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false
See original GitHub issueElectronNET version: 7.30.2 .NET Core 3.0.1 (produces the same issue with v3.1.0)
(project that reproduces the behavior is attached)
Create an ElectronNET based Blazor project with the standard steps
mkdir BlazorOnReadyIssue
cd BlazorOnReadyIssue
dotnet new blazorserver --no-https
dotnet add package ElectronNET.API
dotnet new tool-manifest
dotnet tool install ElectronNET.CLI
dotnet electronize init
- Set up
Program.cs
:
// ...
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>()
.UseElectron(args); // --- Added this
});
// ...
- Set up
Startup.cs
:
// --- At the end of Configure
// ...
Task.Run(async () =>
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
new BrowserWindowOptions
{
Title = "OnReadyToShow",
Width = 1152,
Height = 864,
Show = false // --- When set to true, project works properly
});
browserWindow.OnReadyToShow += () => browserWindow.Show();
});
- Run the project (either with Ctrl+F5 or
electronize start
)
Expected behavior: The Electron Shell window is displayed with the Blazor App.
Issue: The Electron Shell window does not display.
Whenever I change the Show
property of BrowserWindopOptions
to true
, the project works fine, but, of course, for a few seconds an empty page is displayed according to the normal behavior.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Blazor in Electron: Window not showing
Trying to run a Blazor Server App inside an Electron shell. ... not work. Looks like the app bootstraps, but Electron window does...
Read more >Run Blazor Apps Within Electron Shell | The .NET Tools Blog
In this post, we'll go one step further and see how we can embed Blazor into an Electron app to ship Blazor on...
Read more >Blazor on Desktop
Let's take a closer look at desktop apps powered by Blazor—we'll explore two popular ways for some clarity and see the desktop shells...
Read more >ASP.NET Core Blazor forms and input components
Learn how to use forms with field validation and built-in input components in Blazor.
Read more >Electron.NET changelog - Awesome .NET - LibHunt
Fixed bug: Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false #361; Fixed...
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 FreeTop 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
Top GitHub Comments
Fixed in the next Electron.NET Version 8.31.1.
@Dotneteer We authors are both fathers at the moment… and are therefore a bit limited in time… I will work on a new version for the days… But you can also support or sponsor us with pull requests 😃
I’ll take a closer look at your problem.