electronelectron-builderelectron.net

Electron NET doesn't run in Production mode in win10


Iam using asp.net core razor pages with Electron NET in debug the Electron app its run with no errors whene i build it using electron cli

>electronize build /target win

and run the setup it installed and the app appears on task manager but no window my code:in startup

  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseMigrationsEndPoint();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

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

        app.UseRouting();

        app.UseAuthentication();
        app.UseAuthorization();
        app.UseEndpoints(endpoints =>
        {

            endpoints.MapRazorPages();
        });
        if (HybridSupport.IsElectronActive)
        {
            
            CreateWindow();
        }
    }
    private async void CreateWindow()
    {
        var window = await Electron.WindowManager.CreateWindowAsync();
        
        window.OnClosed += () => {
            Electron.App.Quit();
        };
    }

and in program:

 public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseElectron(args);

                webBuilder.UseStartup<Startup>();
            });

Solution

  • its work properly when i use mvc project not razor pages