question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false

See original GitHub issue

ElectronNET version: 7.30.2 .NET Core 3.0.1 (produces the same issue with v3.1.0)

(project that reproduces the behavior is attached)

BlazorOnReadyToShowIssue.zip

Create an ElectronNET based Blazor project with the standard steps

  1. mkdir BlazorOnReadyIssue
  2. cd BlazorOnReadyIssue
  3. dotnet new blazorserver --no-https
  4. dotnet add package ElectronNET.API
  5. dotnet new tool-manifest
  6. dotnet tool install ElectronNET.CLI
  7. dotnet electronize init
  8. Set up Program.cs:
// ...
public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
             webBuilder
                 .UseStartup<Startup>()
                 .UseElectron(args);  // --- Added this
        });
// ...
  1. 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();
});
  1. 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.

VsDebugConsole_mpnXKwDexe Taskmgr_5k2ICKnU0m

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:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GregorBiswangercommented, Apr 21, 2020

Fixed in the next Electron.NET Version 8.31.1.

1reaction
GregorBiswangercommented, Apr 17, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found