Electron NET 在 win10 中不在生产模式下运行

问题描述

我在 Electron NET 中使用 asp.net core razor 页面 在调试 Electron 应用程序时,当我使用电子 cli 构建它时,它的运行没有错误

>electronize build /target win

并运行它安装的设置,应用程序出现在任务管理器上但没有窗口 我的代码:在启动

  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();
        };
    }

并在程序中:

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

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

解决方法

当我使用 mvc 项目而不是剃刀页面时,它可以正常工作

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...