Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron GUI with C# backend

Use case

I've got an existing project developed in C# using WinForms with custom controls for the GUI. We are amazed by the approach to write GUIs using HTML/CSS/JS and we are looking for the best way to write a GUI for our desktop application using the above mentioned languages. We only need to support Windows devices.

My worries:

It doesn't take long to come across recommendations using electron-edge. While I am not so worried to get everything working, I am worried about:

  1. Debugging my C# code (I still want to be able to start my whole application right from VS and debug it look I am used to it). I read that I would need to attach to the node.js application in order to debug my C# code afterwards. Since the whole program language is written in C# that sounds like a pain?
  2. As far as I got edge will let it run as just one process. Can I consider the electron application as an own thread which would still run while my C# code is stuck somewhere?

My option:

I am still positive I want to write my desktop GUI with HTML/CSS/JS. What I considered instead of using electron-edge is writing an own electron application which does communicate with my C# backend using named pipes. I wonder if there are larger roadblocks why I wouldn't want to do this and use electron-edge instead?

My question:

I would like to get feedback for my two concerns mentioned above and I also would like to get input about my option to create the GUI as own electron process, so that I have two processes (GUI+Backend) when someone runs my application.

like image 822
kentor Avatar asked Aug 08 '17 23:08

kentor


People also ask

Is Electronjs obsolete?

Here's the truth, Electron is an obsolete technology. Despite it currently being used by an extensive number of desktop applications, many of those are already having plans to convert their existing Electron-based desktop apps to PWA.

Can you use C# with Electron?

And as it is C# core, it is cross-platform as well. Cross-platform desktop app powered by Electron using React for UI and extended functionality by C# goodness. And now not only you can use your frontend skills, but backend as well.

Is Electron good for desktop?

Overall, if you want to use JavaScript everywhere, and don't care much about performance or security, Electron is a pretty good choice. However, if you have any performance considerations, need mobile support, or want optimal security, you probably will not want to use Electron.

Is Electron a GUI?

It was originally built for Atom. Electron is the main GUI framework behind several open-source projects including Atom, GitHub Desktop, Light Table, Visual Studio Code, WordPress Desktop, and Eclipse Theia.


2 Answers

Electron.NET may be a option for you. You can write c# code with electron.

like image 169
cuixiping Avatar answered Sep 28 '22 04:09

cuixiping


You can do it in many ways

1) COM. Create C# COM DLL. Create wrapper functions for the DLL using N-API (Native node module) or use FFI. You can access the functions from JS.

2) Create a .Net web server and include your functions as REST endpoints. From UI make http request to communicate (Clear separation of UI & BEnd)

You can checkout my github repo for a few alternatives to electron.

like image 22
Sudhakar Ramasamy Avatar answered Sep 28 '22 04:09

Sudhakar Ramasamy