Error on reloading a window after a second window is closed #760

Open
opened 2026-01-29 16:47:52 +00:00 by claunia · 0 comments
Owner

Originally created by @dlitty on GitHub (Feb 17, 2022).

  • Version: latest (13.5.1)
  • .NET 5
  • Target: None; electronize start will reproduce

Using the latest Electron.NET API & CLI: if an application has two windows open, then one of them is closed, and you call Reload() on the first one, an error occurs:

A Javascript error occurred in the main process
Uncaught Exception: TypeError: Object has been destroyed
at BrowserWindow.<anonymous>( ... path ... /obj/Host/api/browserWindows.js:205:55 ...

Steps to Reproduce:

  1. Create a new .NET 5 ASP.NET web application
  2. Follow the instructions in the readme to set up Electron.NET in the project
  3. Instead of Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());, use:
    Task.Run(async () => 
    {
        var mainWindow = await Electron.WindowManager.CreateWindowAsync();
        var secondWindow = await Electron.WindowManager.CreateWindowAsync();
        secondWindow.Close();
        mainWindow.Reload();
    }

Alternatively, comment out the Close and Reload lines, and manually close one window and hit Cmd-R on the other.

Originally created by @dlitty on GitHub (Feb 17, 2022). <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: latest (13.5.1) <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> * .NET 5 <!-- What target are you building for? --> * **Target**: None; `electronize start` will reproduce <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> Using the latest Electron.NET API & CLI: if an application has two windows open, then one of them is closed, and you call Reload() on the first one, an error occurs: ``` A Javascript error occurred in the main process Uncaught Exception: TypeError: Object has been destroyed at BrowserWindow.<anonymous>( ... path ... /obj/Host/api/browserWindows.js:205:55 ... ``` Steps to Reproduce: 1. Create a new .NET 5 ASP.NET web application 2. Follow the instructions in the readme to set up Electron.NET in the project 3. Instead of `Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());`, use: ``` Task.Run(async () => { var mainWindow = await Electron.WindowManager.CreateWindowAsync(); var secondWindow = await Electron.WindowManager.CreateWindowAsync(); secondWindow.Close(); mainWindow.Reload(); } ``` Alternatively, comment out the Close and Reload lines, and manually close one window and hit Cmd-R on the other.
claunia added the bug label 2026-01-29 16:47:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#760