ElectronNET / Electron.NET

:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).
https://gitter.im/ElectronNET/community
MIT License
7.32k stars 725 forks source link

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

Open YehorPavlenko opened 1 year ago

YehorPavlenko commented 1 year ago

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?

FlorianRappl commented 1 year ago

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!