Hi, I got a problem with a "Hello World" application with VSCode on Ubuntu 22.04.1 LTS. What I did so far is:
Do I need Version 5, too? Or is there something else missing? On my Windows machine I was up and running at this point.
Hey guys, can someone help out, recently i worked on application that i built in .Net MAUI, favoribly enough, its 90% compatible with blazorserver so i decided to utilize Electron.Net to port it respectivly to Linux and Mac as the MAUI side doesn't seem that good as an alternative, installation is tedious and most users can't figure it out.
So, everything ok with porting the application but i can't get the browser window to show, initially Electron.Net.CLI was throwing and error that it doesn't support .Net 6, i had to clone the project and recompile it under .Net 6, so now it seems to be somewhat working. However when i try to dotnet-electronize start using the compiled binary in .Net 6, the application starts as usual but the browser window doesn't open, does anyone have any ideas what might be the issues with this:?
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using LInksync_Cold_Storage_Wallet.Data;
using SYNCWallet.Services.Definitions;
using SYNCWallet.Services.Implementation;
using NFTLock.Data;
using SYNCWallet.Data;
using LInksync_Cold_Storage_Wallet;
using ElectronNET.API;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using ElectronNET.API.Entities;
var builder = WebApplication.CreateBuilder(args);
Electron.App.On("select-client-certificate", (obj) => { Console.WriteLine("select-client-certificate"); Electron.Notification.Show( new NotificationOptions("select-client-certificate", $"select-client-certificate event has been captured") { Silent = false, }); });
// --- Add electron...
builder.Services.AddElectron();
builder.WebHost.ConfigureKestrel(o => {
o.ConfigureHttpsDefaults(o => o.ClientCertificateMode = ClientCertificateMode.RequireCertificate);
}).UseElectron(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddScoped(typeof(IUtilities), typeof(Utilities));
builder.Services.AddScoped(typeof(IHardwareService), typeof(HardwareService));
builder.Services.AddScoped(typeof(IAuthenicationService), typeof(AuthenicationHandler));
builder.Services.AddScoped(typeof(IContractService), typeof(ContractService));
builder.Services.AddScoped(typeof(IPaymentService), typeof(PaymentService));
builder.Services.AddScoped(typeof(ICommunication), typeof(Communication));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
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();
}
var scope = app.Services.CreateScope();
Initializer.Provider = scope.ServiceProvider;
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
// Open the Electron-Window here
System.Console.WriteLine("Starting Main window");
Task.Run(() => {
var window = Electron.WindowManager.CreateWindowAsync();
});
app.Run();
using ElectronNET.API;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
using RageWindowsAplication.Models;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseElectron(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
//Adding Dependency Injection
builder.Services.AddDbContext<QuizDbContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DevConnection")));
var app = builder.Build();
//This config is for allow any external port number appication call the API Methds
//app.UseCors(options=> options.WithOrigins("Https://localhost:3000").AllowAnyMethod().AllowAnyHeader());
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
// 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.UseRouting();
//This is to fix
//Enable the statis files for this API
//And Be able to Load the Images
//for Static file
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.ContentRootPath, "Images")),
RequestPath = "/Images"
});
app.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
app.MapFallbackToFile("index.html");
//Add the Electron
if (HybridSupport.IsElectronActive)
{
CreateWindow();
}
async void CreateWindow()
{
var window = await Electron.WindowManager.CreateWindowAsync();
var Webwindow = await Electron.WindowManager.CreateBrowserViewAsync();
window.OnClose += Window_OncClosed;
window.OnMaximize += Window_OnMaximize;
window.OnMinimize += Window_OnMinimize;
}//end CreateWindow
void Window_OncClosed()
{
Electron.App.Exit();
}//end Window_OncClosed
void Window_OnMaximize()
{
Electron.Dialog.ShowErrorBox("Demo Maximized Envent", "Hi, you Just maimixed you Electron App");
}//end Window_OncClosed
void Window_OnMinimize()
{
Electron.Dialog.ShowMessageBoxAsync("Ventana minimizada");
}//end Window_OncClosed
app.Run();
I'm trying to build an application for mac and Windows and I'm running into an issue right now. When I run Electronize start on my mac I get a blank electron window and the console reads the following
"(node:14402) electron: Failed to load URL: http://localhost:8002/ with error: ERR_CONNECTION_REFUSED"
If I go to the menubar and click refresh the page loads and I get another message
"warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect."
please let me know what information would be helpful in getting past this thank you!
changing this line
var browserWindow = await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);
to this
async void CreateWindow()
{
var window = await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);
window.OnClosed += () => {
Electron.App.Quit();
};
}
fixed the issue
Hello. I'm another person struggling to get this working in .net 6. Right now I'm just trying to get the example running. I built the repo and did
dotnet C:\Users\chris\source\repos\Electron.NET\ElectronNET.CLI\bin\Debug\net6.0\dotnet-electronize.dll start
inside the ElectronNET.WebApp folder. I see some errors in the output:
npx tsc -p ../../ElectronHostHook
../../ElectronHostHook/connector.ts(2,33): error TS2503: Cannot find namespace 'SocketIO'.
../../ElectronHostHook/excelCreator.ts(1,24): error TS2307: Cannot find module 'exceljs' or its corresponding type declarations.
../../ElectronHostHook/excelCreator.ts(2,37): error TS2307: Cannot find module 'exceljs' or its corresponding type declarations.
../../ElectronHostHook/index.ts(7,25): error TS2503: Cannot find namespace 'SocketIO'.
and the demo app fails to launch with:
stderr: System.Exception: You need to run once the electronize-h5 start command to bootstrap the necessary files
at ElectronNET.API.Electron.Experimental.StartElectronForDevelopment(Int32 webPort, String projectPath, String[] extraElectronArguments, Boolean clearCache) in ?>C:\Users\chris\source\repos\Electron.NET\ElectronNET.API\Electron.Experimental.cs:line 58
at ElectronNET.WebApp.Program.Main(String[] args) in C:\Users\chris\source\repos\Electron.NET\ElectronNET.WebApp\Program.cs:line 22
at ElectronNET.WebApp.Program.<Main>(String[] args)stderr: System.Exception: You need to run once the electronize-h5 start command to bootstrap the necessary files
at ElectronNET.API.Electron.Experimental.StartElectronForDevelopment(Int32 webPort, String projectPath, String[] extraElectronArguments, Boolean clearCache) in >C:\Users\chris\source\repos\Electron.NET\ElectronNET.API\Electron.Experimental.cs:line 58
at ElectronNET.WebApp.Program.Main(String[] args) in C:\Users\chris\source\repos\Electron.NET\ElectronNET.WebApp\Program.cs:line 22
at ElectronNET.WebApp.Program.<Main>(String[] args).NET process exited with code 3762504530
Will quit Electron, as exit code != 0 (got 3762504530)
TypeError: Error processing argument at index 0, conversion failure from null at Socket ...
Hi, I'm having trouble getting Electron.NET to behave nicely in the basic dotnet NET6 ASPNET.Core template app.
When running the app normally via its default launch profile, the website connects to the API just fine via localhost:44408/weatherforecast
.
When running from commandline via electronize start
or electronize start /watch
, it cannot connect to the API. I do notice, however, that localhost:8001/weatherforecast
works, which is the "Electron Port" which I haven't actually set up anywhere.
When trying to run the launch profile added by Electron.NET, it results in "catastrophic failure" altogether.
Basically, as a newbie, I can't make sense of this port salad and I'm not sure what I'm supposed to be doing, given that I feel I've followed official instructions, but an otherwise unchanged default dotnet app with default api example is failing to work.