22

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.

arthurakay
  • 5,631
  • 8
  • 37
  • 62
kentor
  • 16,553
  • 20
  • 86
  • 144
  • One of your concerns is still being able to start the whole application right in Visual Studio? How long do you think it will take you to start Node.js via command line and than hit CTRL + ALT + P in VS to attach to process? – Brian Ogden Aug 08 '17 at 23:25
  • I've never tried it but if I have to do this every time I (re)compile my application I am sure this would be indeed very annoying for me and my colleagues – kentor Aug 08 '17 at 23:28
  • May'be this link can help you: https://github.com/bridgedotnet/Widgetoko – isaeid Apr 18 '18 at 09:58
  • Do you even need Electron? Windows supports JavaScript (and HTML/CSS) as a first-class language for native Windows applications (branded as [UWP Apps](https://msdn.microsoft.com/en-us/magazine/mt632270.aspx)) – arthurakay May 09 '19 at 01:48
  • 1
    I believe UWP is restricted to Windows Store distribution. – Captain Prinny Jul 08 '19 at 16:23
  • https://github.com/mandrepont/blazetron and https://github.com/aspnet/Blazor/issues/74 for reference – Kalten Sep 13 '19 at 19:22

3 Answers3

8

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

cuixiping
  • 24,167
  • 8
  • 82
  • 93
3

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.

Sudhakar Ramasamy
  • 1,736
  • 1
  • 8
  • 19
0

I think a most import question would be how your frontend interacts with the backend? Is there any notifications need push to the frontend?

WebSocket could be a good option for two ends communication.

Andy
  • 31
  • 1
  • 4