Hi Lemmings, I wondered if anyone had successfully created a C# project that uses winforms on linux.
I just can’t figure out how to do it.
I use Arch and have full dotnet 6 and 8 packages; but I can’t dotnet new winforms
as the template seems to not exist.
I also have installed mono and monodevelop installed, but even the simplest solution (Console App) can’t load correctly (currently I have /usr/share/dotnet/sdk/8.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5) : error MSB4062: The "CheckForImplicitPackageReferenceOverrides" task could not be loaded from the assembly /usr/share/dotnet/sdk/8.0.102/Sdks/Microsoft.NET.Sdk/targets/../tools/net472/Microsoft.NET.Build.Tasks.dll. Invalid Image Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
but there were different similar errors before, these errors.
I don’t really want to boot up a VM every time I have to code on that project, but I’m starting to feel desperate about this.
TLDR: How does one create and work on a WinForms C# project with linux ? Any suggestions are welcome
Some clarifications for future readers :
- It is for a school group project; winforms in imposed, which sadly won’t let me go with Avalonia
OP,
Here’s a friendly reminder that programming.dev has a community dedicated to .NET: !dotnet@programming.dev
This isn’t an answer to your question.
I’m just curious, why winforms? Is there something that they do really well that you’re just dying to use on Linux? Trying to get a legacy application working? Familiarity?
none of that; it’s a school project which imposed winforms, else I’d have found some thing that would have worked for my linux
That syllabus likely assumes Windows. C# on non-Windows is not impossible, but it’s going to require effort infeasible for school projects like that one. As you’re facing it, C#'s packages were originally not meant to be used cross-platform, and god only knows the amount of problems that lie ahead. That clearly didn’t occur to the teacher’s head while they designed the course.
C# on non-Windows is not impossible, but it’s going to require effort infeasible for school projects like that one.
You mean winforms (The windows specific UI) on non-Windows? Otherwise this is incredibly misleading, and plain wrong.
C# in non windows is the norm, the default even, these days. I build, compile, and run, my C# applications in linux , and have been for the last 5+ years.
The “Win” in Winforms stands for Windows, capital W. It’s simply not available for Linux.
Mono has some docs that imply they have implemented WinForms on X11.
Official source (emphasis mine)
Welcome to the Desktop Guide for Windows Forms, a UI framework that creates rich desktop client apps for Windows.
Check out Avalonia. It’s like cross platform WPF. Not winforms, but still pretty good and easy to start with.
The closest I got was by just using avalonia. I had to use winforms for my uni and convincing my teachers to allow my team to use avalonia was not easy. Avalonia is not even remotely similar to winforms. You can try setting up a VM, but I understand that it is not a real solution. I found some docs for an old version of mono which referenced some of the winforms API, but I had no luck running it.