mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Net6 BlazorServerSide #781
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @torsilver on GitHub (Apr 12, 2022).
Originally assigned to: @GregorBiswanger on GitHub.
I am trying out the Blazor ServerSide program for Net6
Follow the instructions in README
After I type "electronize Start"
The console display is as follows
Electron Socket IO Port: 8000
Electron Socket started on port 8000 at 127.0.0.1
ASP.NET Core Port: 8001
But nothing happened
What should I do, please?
@Isaac-jairi commented on GitHub (Apr 12, 2022):
Same question here
@danatcofo commented on GitHub (Apr 12, 2022):
Given that those ports are often used by other apps in dev id recommend choosing different ports but otherwise just run the app directly. You've probably got some startup bug causing the dotnet app to crash.
I don't think the fix to grab the error steam from the dotnet process has been released to nuget yet so it can crash silently.
@dealproc commented on GitHub (Apr 18, 2022):
Drop your startup code. You may not be wiring something up correctly.
@torsilver commented on GitHub (May 6, 2022):
hello
Sorry for the late reply
Below is my "program.cs" file
So far the problem remains
Please take a look at it for me if you have time
`using BlazorNet6WithElectron1.Data;
using ElectronNET.API;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseElectron(args);
});
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
//app.Run();
Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());`
@torsilver commented on GitHub (May 6, 2022):
hello
Sorry for the late reply
Below is my "program.cs" file
So far the problem remains
Please take a look at it for me if you have time
`using BlazorNet6WithElectron1.Data;
using ElectronNET.API;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseElectron(args);
});
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
//app.Run();
Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());`
@dealproc commented on GitHub (May 12, 2022):
I'm just getting back into ElecronNET, but I did an experiment a while back on it, and my implementation was:
The biggest thing to note is that the window is being configured / shown only when it's ready to be shown, and I'm providing the window parameters immediately.
I'm trying to locate the recent bits I did in dotnet 6 to see if there's a difference from what this is.
@Heartnett commented on GitHub (Aug 20, 2022):
I've got the window to render on my side.
Here is how I did it:
Step 1 - Enable Electron Support
It turns-out that this code 👇 will "freeze" the
electronize startprocessBy running the app normally (
dotnet run) I received this output message:After a bit of digging I found that the
WebApplicationBuilderclass (buildervariable) has aWebHostproperty which implements theIWebHostBuilderinterface.UseElectronis an extension method for this interface.Step 2 - Setup The Electron Window
The Electron window setup and initialization must happen before running the server-side
appinstance, otherwise it won't work.Step 3 - Run The Server-Side App
Finally, run the server-side app after setting-up the Electron window and whatever else.
Here is my
Program.csfile:@GregorBiswanger commented on GitHub (Mar 28, 2023):
🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉
With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!