ElectronNET app is not running when I`m adding services in .net core 6 #870

Closed
opened 2026-01-29 16:50:48 +00:00 by claunia · 2 comments
Owner

Originally created by @YehorPavlenko on GitHub (Apr 4, 2023).

My electron App is not running when I`m adding services in the Program file.

The program file looks like

using ElectronNET.API;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseElectron(args);

builder.Services.AddElectron();
builder.Services.AddControllersWithViews();
builder.Services.AddTransient<SomeInterface, SomeClass>();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller}/{action=Index}/{id?}");

app.MapFallbackToFile("index.html"); 

await app.StartAsync();

await Electron.WindowManager.CreateWindowAsync();

app.WaitForShutdown();

But when I remove

builder.Services.AddTransient<SomeInterface, SomeClass>();

it runs perfectly.
Any ideas how to solve this?

Originally created by @YehorPavlenko on GitHub (Apr 4, 2023). My electron App is not running when I`m adding services in the Program file. The program file looks like ```C# using ElectronNET.API; var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseElectron(args); builder.Services.AddElectron(); builder.Services.AddControllersWithViews(); builder.Services.AddTransient<SomeInterface, SomeClass>(); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); app.MapFallbackToFile("index.html"); await app.StartAsync(); await Electron.WindowManager.CreateWindowAsync(); app.WaitForShutdown(); ``` But when I remove ```C# builder.Services.AddTransient<SomeInterface, SomeClass>(); ``` it runs perfectly. Any ideas how to solve this?
claunia added the more-information-needed label 2026-01-29 16:50:48 +00:00
Author
Owner

@FlorianRappl commented on GitHub (Apr 4, 2023):

Are you sure that this issue has anything to do with Electron.NET?

Sounds that your class may miss a default constructor or something similar. Please

  1. Make sure that you have valid code, i.e., that it runs in general
  2. You can reproduce the issue in a MWE that you can give us in form of a GitHub repository (such that we only need to clone and open to see the issue appearing on our machines)

Thanks!

@FlorianRappl commented on GitHub (Apr 4, 2023): Are you sure that this issue has anything to do with Electron.NET? Sounds that your class may miss a default constructor or something similar. Please 1. Make sure that you have valid code, i.e., that it runs in general 2. You can reproduce the issue in a [MWE](https://en.wikipedia.org/wiki/Minimal_reproducible_example) that you can give us in form of a GitHub repository (such that we only need to clone and open to see the issue appearing on our machines) Thanks!
Author
Owner

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

Outdated - use ElectronNET.Core and ElectronNET.Core.AspNet.

See Wiki / What's New.

@FlorianRappl commented on GitHub (Nov 1, 2025): Outdated - use `ElectronNET.Core` and `ElectronNET.Core.AspNet`. See [Wiki / What's New](https://github.com/ElectronNET/Electron.NET/wiki/What's-New).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#870