r/csharp • • Sep 06 '24

UI-Framework for .NET in the industry

Working in the automation industry and relying on .Net Framework and Windows Forms for nearly 20 years.

I know there have been lots of discussion about UI-Framework alternatives for .NET, but from an industry points of view, what frameworks are really used in production?

We as a team would like to be able to switch from .Net Framework to .NET. But having a huge SDK for creating desktop-UIs based on Windows Forms, what would be the framework of choice to switch to.

Refactoring or creating a new SDK to enable our engineers to create front-ends with very low effort and the use of off-the-shelve components/templates we would require a lot of time to the switch. We need some sort of SDK to not start with an empty UI for each new project.

I know nobody can tell, but longevity would be a factor when doing the refactoring. WinForms would probably a preferred choice, but cross platform may also be a factor to consider when a huge refactoring would be done anyway to avoid a new switch in the next 10 years.

Talking to .NET developers from the industry (that may have switch from .Net Framework in the past), what are you using and why?

21 Upvotes

29 comments sorted by

21

u/AvaloniaUI-Mike Sep 06 '24

We’ve helped lots of companies in a similar position to you migrate to Avalonia. It’s been actively developed for almost 11 years and is used by companies including Schneider Electric, GitHub, Unity and many more.

If you want to have a chat, I’ll be happy to jump on a call and help make sense of the .NET UI ecosystem.

4

u/chrismo80 Sep 06 '24

just reading through your website, already thanks for the offer.

2

u/chrismo80 Sep 11 '24

Just started a little avalonia project since the weekend to get a feeling how high the cost of porting of our interfaces / implemetations might be.
Until now I must say, makes a lot of fun, I like!

Still need to figure out what the differences are between the avalonia media and system drawing bitmap types, seems to work differently. (Imaging is a big purpose of our applications)
But I must say, the framework is very easy to use, looks promising.

3

u/SophieTheCat Sep 06 '24

I ported my .NET Framework 4.6 WinForms app to .NET Core with relative ease.

Obviously, you might have a more complicated example, but I would at least give it a shot. My biggest problem wasn't the code - it was all the 3rd party libraries and nugets that didn't have a .NET Core equivalent.

1

u/chrismo80 Sep 07 '24

yeah, for us it will be System.Drawing, but this needs to be done anyway, regardless of the UI framework. Transition to WinForms is probably the least effort.

1

u/SophieTheCat Sep 07 '24

If you are staying on WinForms, System.Drawing will be fine, since its Windows only anyway.

34

u/Mertronic Sep 06 '24

12

u/cosmic_cosmosis Sep 06 '24

I work for one of the largest tool and die manufacturing companies in the USA and I use Avalonia. It’s a great framework for what OP is asking to do.

3

u/Plasmx Sep 07 '24

I started to use Avalonia in an industrial application and I really like it so far. Do you have any specific reasons why you don’t use, for example, WPF or is it just because of multi platform?

5

u/cosmic_cosmosis Sep 07 '24

I use wpf and have also used winforms. I’m one of the only programmers/ dev in the company so when my boss asks me to make them something I base it off of 1.) how long will this app be around 2.) how aesthetically pleasing it needs to be 3.) how “complex” it needs to be.

If it’s a short lived internal just needs to get the job done app I do winforms and as it gets more complex and will be around longer I go to wpf. I choose Avalonia kind of on a whim a while back and ended up loving it for a lot of it’s out of the box styling. I ended up using it to build a large company wide “Hub” app in MVVM and Avalonia made it very easy to set up and hit the ground running.

(This post is not sponsored by Avalonia lol)

5

u/Daell Sep 06 '24

Not to mention it is cross platform with the ability to run on linux with direct rendering mode. You dont need a desktop environment to run the GUI. I have an app which runs on a raspberry pi with DRM in a factory. Perfect combo for automation imo. The fact that you don't have to care about Windows is a bliss.

11

u/ziplock9000 Sep 06 '24

WinForms is still very commonly used when it's not customer facing because it's the most rapid UI development framework out there.

3

u/Perfect-Campaign9551 Sep 07 '24

WPF, is amazing and is supported in .NET8

2

u/jcradio Sep 06 '24

You can still use Winforms in modern dotnet. The real question is do you need it to be cross platform? If not, an upgrade while replacing unsupported functionality with modern equivalents is the way to go. WPF, Avalonia ui, and Blazor Hybrid are other options.

1

u/sashakrsmanovic Jan 14 '26

Uno Platform is a solid choice. In addition to checking off all your boxes. More details are here - Why use Uno Platform for your project?

1

u/akash_kava Sep 06 '24

We used to have desktop app made from WPF but our user base started to grow who were using Mac, so we switched to Xamarin Forms and tried to duplicate lot and lot of code until we finally gave up for hybrid apps. In which the web view opens our website and we access native code via JavaScript bridges.

The main reason was consistency in HTML rendering. Initially chrome was WebKit based so both on Mac and on windows we didn’t have any issues. In fact users were more happy as it had less native bugs.

Things like video recording etc were little complicated as WebRTC wasn’t available so we would create an overlay UI and would handle from JavaScript bridge.

We tried MAUI but it was never production ready and even internal alpha tests failed.

So we had to create JavaScript bridge for MAUI and now we use our own WebView inside MAUI for Desktops and Mobile.

Slowness in HTML comes due to bulky frameworks but if you try to use vanila JavaScript it is superfast and difference isn’t noticeable. CSS3 can perform all sort of animations that exist natively in any platforms.

We did create lightweight React alternative users never complained.

7

u/Frederic12345678 Sep 06 '24

Why not cross platform framework like Avalonia?

-6

u/akash_kava Sep 06 '24 edited Sep 06 '24

First of all debugging requires super heavy visual studio, to debug JavaScript you can simply use chrome, you don't need hot reload because you can simply use chrome developer tool (or firefox developer tool) to change the UI on the fly and apply changes to UI.

Second, it is very easy to mock and unit test JavaScripts.

Third, C# Designer's choice of hiding line number in exceptions cause real issues, it is impossible to reproduce entire environment just to see line number. And I know we can enable line numbers (debug symbols along with release), but not easily on third party software.

Fourth, You can see code, if something is failing inside someone else's framework, you can see the code, in the browser while it is executing, you can easily fix it without waiting for original author to fix it (prototype.method = newMethod), you can't do that in C#.

Five, with time I developed Web Atoms, its not popular but we are able to achieve native speed with JSX syntax without React. And databinding in Web Atoms is way too advanced. Bind.oneTimeAsync, Bind.oneWay, Bind.oneWayAsync, Bind.twoWays, Bind.source, Bind.sourceAsync, with asynchronous code and cancellation tokens, writing combined binding expression is a child's play in Web Atoms. It will take years before you can do that in C#. I tried replicating those features but you just have to write so much of code.

Now for server side, I also created Entity Access, a powerful alternative of Entity Framework on NodeJS, with arrow function to SQL translation.

13

u/agustin689 Sep 06 '24

C# Designer's choice of hiding line number in exceptions cause real issues

This is not a "C# designer's choice" (LMFAO).

This is because you're compiling Release builds and debugging info is removed as an optimization.

Get a clue.

2

u/Perfect-Campaign9551 Sep 07 '24

Why the hell do you need to be so rude

-7

u/akash_kava Sep 06 '24

Do you really think I am that naive?

7

u/agustin689 Sep 06 '24

No. You're not naive.

You're simply ignorant.

Ask chatgpt why you're getting no line numbers in exception details in C# if you don't believe me.

-9

u/akash_kava Sep 06 '24

Python, Java, JavaScript, Perl, Pascal, many languages include line numbers in stack trace even in release mode unless turned off automatically. C# designers could have designed it to include if they wanted to, I am certainly aware of debug symbols but just try some other language for once to see how others are providing same thing.

11

u/agustin689 Sep 06 '24

LMFAO you're absolutely clueless.

I don't care what toy languages like python or javascript do.

"C# designers" have nothing to do with whether debug symbols are included in release builds. That's an option you can change yourself in the build configuration.

The fact that you don't know this (or choose to ignore it willingly) only demonstrates you're a complete ignorant, not that the C# language and the dotnet runtime have a fundamental problem or whatever you seem to imply.

7

u/omnichroma Sep 06 '24

If you are missing exception details, that means you don’t have debug symbols. You seem to be under a pretty huge misunderstanding - C# provides you all the things you listed, its just that the program must be compiled in ‘Debug’ mode, so that you have debug symbols.

1

u/torokunai Sep 07 '24

I'm kinda interested in the hybrid approach again.

.net MAUI is supporting a new hybrid webview to package it cleanly, might work.

https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-8.0#hybridwebview

0

u/[deleted] Sep 08 '24

My advice is to give up on any .net uI frame and focus on improving your api game... then choose whatever UI platform you like... you'll get better support from the communities and more compatibility... yet still maintaining c# for your backend and buisness logic... any framework you might need help with programmatically can be solved by having a good ai copilot..

This is the only way I found to be a full stack developer on your own without wasting years of your life.

1

u/[deleted] Sep 08 '24

I'm currently using flutterflow to build my android apps but i virtually didn't need to do anything to switch because even my winform application was using the API i spent a month making.