Electron.NET
Electron.NET copied to clipboard
Failed to bind to address http://127.0.0.1:5000: address already in use
23.6.1. Thank you for the version!
I have a small NET 6 client app which connects to a NET Web service on other machine. It works in Windows, ok. I have build in Windows for Linux:
electronize build /target linux ok, then copied bin\Desktop folder to Ubuntu. In Ubuntu go to internal folder and run ~/Moomoo/Desktop/linux-unpacked/resources/bin$ ./MyClient
Finally received: Unhandled exception. System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use. ---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
After a search I can say : I do not use this address and port. Also, why it busy - I have no clue. What is ti and how to fix it?
It was my not started app, ok. I have killed the process and run app again (in terminal) But I do not see a GUI, the console output only:
info: Microsoft.Hosting.Lifetime[0] Application is shutting down... info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: /home/xoleg/Moomoo/Desktop/linux-unpacked/resources/bin/
Btw, when I have built for windows and run it - it works fine
This is from ASP.NET Core. When it is launched in production, it has the default ports 5000 and 5001. You can also influence this yourself. Add the following line of code to your Program.cs:
webBuilder.UseUrls("http://0.0.0.0:<port>");
Please tell me if it worked.
Or better yet, via the appsettings.json, try this instead.
Thank you Gregor, please read my 2nd question here: why I see the console output only in Ubuntu instead of GUI? In the same time I can build and run a desktop app in windows- OK!
I even can provide you my zipped project to check if needed
To run a Linux desktop application in WSL2 (Windows Subsystem for Linux 2) with a graphical user interface (GUI), you need to install an X Window System server for Windows, which will act as a display server for the Linux applications. One of the popular options is VcXsrv. Here are the steps to run a Linux desktop application with a graphical user interface in WSL2:
- Install WSL2 on your Windows system, if you haven't already. You can find instructions in the official Microsoft documentation: https://docs.microsoft.com/en-us/windows/wsl/install
- Install a Linux distribution of your choice from the Microsoft Store (e.g., Ubuntu, Debian, Fedora Remix).
- Install VcXsrv or another X Window System server. Here's the link to VcXsrv: https://sourceforge.net/projects/vcxsrv/
- Launch VcXsrv and select your desired settings. Make sure to enable "Disable access control" to avoid connection issues.
- Set the DISPLAY environment variable in your WSL2 shell to use the X server:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0 - Run the Electron.NET Linux application in the WSL2 shell:
electronize start
The application should now be displayed on your Windows desktop in its own window. Note that while this method works for many applications, some may experience performance or compatibility issues.
Alternatively, you can use Windows 11, which provides native support for WSLg (Windows Subsystem for Linux GUI). This allows for easy running of Linux GUI applications directly from WSL without needing to install a separate X Window System server. You can find more information here: https://aka.ms/wslg
Thank you. but in my case I have a physical machine with Ubuntu in a LAN And I wanted to do real experiment to build my Desktop app Windows for Linux, copy it to Ubuntu and run. All works but I do not see GUI. The same desktop app build for win works fine.
If you have a physical machine running Ubuntu in your local network and you want to run a Linux desktop application with GUI from your Windows machine, you can use a remote desktop protocol like VNC or X11 forwarding over SSH to display the GUI on your Windows machine. I'll explain both methods below.
Method 1: VNC
- Install a VNC server on your Ubuntu machine. For example, you can use TightVNC:
sudo apt update
sudo apt install tightvncserver
- Start the VNC server on your Ubuntu machine:
vncserver
Follow the prompts to set a password for remote access.
-
Install a VNC client on your Windows machine. For example, you can use RealVNC Viewer: https://www.realvnc.com/en/connect/download/viewer/
-
Launch the VNC client on your Windows machine and enter the IP address of your Ubuntu machine followed by the display number (e.g., 192.168.1.100:1). Enter the password you set earlier when prompted.
-
The Ubuntu desktop should now be displayed on your Windows machine, and you can run the Linux desktop application with GUI.
Method 2: X11 Forwarding over SSH
- Install an X Window System server on your Windows machine, like VcXsrv: https://sourceforge.net/projects/vcxsrv/
- Launch VcXsrv with the "Multiple windows" option and enable "Disable access control" to avoid connection issues.
- Install an SSH client on your Windows machine that supports X11 forwarding, like PuTTY: https://www.putty.org/
- Launch PuTTY and enter the IP address of your Ubuntu machine. In the "Category" tree on the left, go to Connection > SSH > X11, and enable "Enable X11 forwarding."
- Click "Open" to start the SSH session with your Ubuntu machine.
- Once connected, run the Linux desktop application with GUI in the SSH terminal:
electronize start
The application's GUI should now be displayed on your Windows machine.
Please note that both methods may have some latency or performance issues depending on your network conditions. If you are building a cross-platform application, consider using a framework like Electron or Qt that allows you to build and test the application natively on both Windows and Linux.
Thank you, my case is much simpler: I have built my app for linux, copied to Ubuntu machine (physical), go to (zu Fuss) the Ubuntu , open the directory. double click on executable file - silence. Then I have found it in terminal, run >./mysvc it runs and shows me console output only. Finally: I cannot see GUI. But in windows it works fine.
How did you create your project for Linux? Do you have the .NET SDK and your project on the Linux? Electron.NET CLI installed and electronize start executed? Or on the Linux electronize build /target linux?
Hi, I work in Windows 10. All NET SDK installed. The freshest Electron Cli installed too and i use in my project the freshest NuGet. My tests: (build an app for Windows or Linux but working in Windows)
- Windows:
electronize build /target win Ok, I go to D:\MyProjects23\Blazor\CAMS.Client.Deskop\bin\Desktop\win-unpacked run CAMS.Client.exe It started and works - OK!
- Build for linux but working in the samw W10
electronize build /target linux Ok, I go to D:\MyProjects23\Blazor\CAMS.Client.Deskop\bin\Desktop Copy it to Ubuntu folder I go to Ubuntu machine. Go to this folder Home\sharedfolder\Desktop\linux-unpacked\resources\bin run CAMS.Client (exectuable) It started - but as console app only without GUI
I can send you my project zip.
Okay, the same directory on the machine for different platforms still has difficulties. I'll add support for that.
Please try the following steps:
1, Copy your project to a new directory
2, At the new directory, delete the obj directory
3, Now try electronize start from Linux from the new directory
Does this work?
What is interesting: again appeared disconnect etc... during the building. Please see in attached file eNET.txt
I work on Windows and have an idea to provide my app for windows, linux and macos users. So I have a building environment on my Windows machine. I will do what you recommended on windows machine.
electron-builder wants to download the native Electron for bundling.. probably won't get access
For Mac build you need an Mac device
electron-builder wants to download the native Electron for bundling.. probably won't get access
Btw, yesterday I did not see this kind of messages.
For Mac build you need an Mac device
I.e. I can build for Win and Linux using Windows , but for MacOS - I should use MacOS. Correct?
Yes, MacOS... But according to the Apple license, the MacOS must also run on a Mac and only then can you create builds for it... It's a legal matter... Technically, everything would also work with a VM and MacOS ;)
Hi Gregor, Its me again ;-) I have made as you recommended above:
- My working machine is W10
- I have deleted /obj and /bin folders
- I have build my Blazor app for windows :
electronize build /target win run it - OK.
-
electronize build /target linux (it is in W10) copied Desktop folder to Ubuntu gave permissions run executable from terminal - it starts as a console app run executable from folder - it does not start. No any GUI in Linux (in W10 - It is)
Btw. I am still hoping to build Desktop app for linux working in Windows (as it was available some years ago in Electron.NET)
Desktop app for linux working in Windows
Do you mean with WSL2?
I work in W10. I develop a Blazor app. Finally I'd like to build it as a Desktop application - exe for windows and provide to users. Ok, I do on my machine:
electronize build /target win
Copy the output folder and give it , user run exe on their Windows machine - OK. Desktop GUI works fine Also, I have Linux users , I build the Desktop for linux on my machine
electronize build /target linux Copy the output folder and give it , user runs executable on their Ubuntu machine - and see consoole output only That is my question: I'd like to run Desktop app in Ubuntu and see the Desktop GUI but not console only as I have now:
I have now tested it locally with Windows 11 - WSL2 + WSLg and Ubuntu 22.04.2 and the Electron.NET demo app opens.
But please try to install Node and .NET SDK on ubuntu and build from Linux. I couldn't build on Windows for Linux. I got an error.
Ah, I see. Some years ago it was possible: to build for win and linux on W10 and it worked. I will try. Btw, can I build for Linux using WSL in the same W10? and then copy a folder to Ubuntu?
But do you have a plan to do it possible again: to build for linux on win?
Good question, I just noticed today that it probably doesn't work anymore?! Whereby WSL2 is a good compromise, which can also be tested straight away.
Great, I and many other wait it. ;-)
we can't change anything about that, it comes from electron-builder. If so then you would need to contact the owner of it.
Hi Gregor,
I work in W10, I can build (electronize) an app for windows - OK. Also, in the same W10 I can build (electronize) the same app for Linux using WSL2 and then copy/provide it for Linux users. Is this correct?
Hi Gregor, Is it in your plans to fix it?
Hi everybody, is any progress for this issue?