Integrating HTML/CSS/JS GUI with C# Backend for Windows Desktop App

Hey everyone,

I’m working on a Windows desktop app and I’m thinking about changing our GUI. Right now we use WinForms with custom controls in C#. But we really like the idea of using HTML/CSS/JS for the interface.

I’ve got a few worries though:

  1. How can I debug my C# code easily? I’m used to doing it straight from Visual Studio.
  2. Will the GUI run smoothly if the C# code gets stuck somewhere?

I’m thinking about making the GUI a separate Electron app that talks to the C# backend through named pipes. Does this sound like a good idea? Or should I use electron-edge instead?

Has anyone tried something similar? What issues did you run into? Any tips or advice would be really helpful!

Thanks in advance for your input!

have you considered using blazor? it lets u use html/css/js for the ui while keeping everything in c#. no need for separate processes or complicated debugging setups. plus, you can still use visual studio for everything. might be worth checking out! what do you think about this approach?

I’ve actually tackled a similar project recently, and I can share some insights. Using HTML/CSS/JS for the GUI can indeed provide more flexibility and modern design options. However, the approach you’re considering with Electron and named pipes might introduce unnecessary complexity.

Instead, I’d recommend looking into using a WebView control within your existing C# application. This allows you to keep your C# backend intact while leveraging web technologies for the UI. You can use frameworks like CefSharp or Microsoft’s WebView2 to embed a browser engine.

This approach offers several advantages:

  1. You can still debug your C# code in Visual Studio as usual.
  2. The GUI remains responsive even if C# operations are running, as they’re on separate threads.
  3. You avoid the overhead of running a separate Electron process.

The main challenge you might face is the initial setup and learning curve for integrating web technologies with C#. But once you’ve got it working, it’s quite powerful and maintainable.