What can and cannot be checked on Linux
The first seven lessons build a WinForms program and say, in passing, that it is not run. This lesson makes that precise, with the real message the machine prints. It is the most important page of Part 1: everything the course claims about a window is either the documented behaviour of the API or a compiler line, and this is the page that shows why.
The build succeeds
The program is the one from lesson 001, in a project called hello with the project file and the nuget.config of the two lessons before:
using System;
using System.Windows.Forms;
internal static class Program
{
[STAThread]
private static void Main()
{
ApplicationConfiguration.Initialize();
Application.Run(new Form { Text = "Hello, WinForms" });
}
}
dotnet build hello.csproj
Build succeeded.
0 Warning(s)
0 Error(s)
The build writes bin/Debug/net10.0-windows/hello.dll, and the compiler had every reference assembly it needed. Nothing about this step is a lie or an approximation: the file is a real Windows program, and the IL inside it is the same IL a Windows machine would produce.
The run fails
Starting it is the step that cannot work here:
dotnet bin/Debug/net10.0-windows/hello.dll
You must install or update .NET to run this application.
App: /tmp/winforms-hello/bin/Debug/net10.0-windows/hello.dll
Architecture: x64
Framework: 'Microsoft.WindowsDesktop.App', version '10.0.0' (x64)
.NET location: /usr/lib/dotnet/
No frameworks were found.
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.WindowsDesktop.App&framework_version=10.0.0&arch=x64&rid=alpine.3.24-x64&os=alpine.3.24
The exit status is 150. The first line names the program by its full path, which is where the build above wrote it on the machine of this run; the rest is verbatim. The message is the host program of .NET reporting that the framework the assembly asks for is not installed: Microsoft.WindowsDesktop.App version 10.0.0, the version line the assembly was compiled against. The .NET location is there and holds two other frameworks, so the message is precise: it is the Windows Desktop framework that is missing.
On Windows the same command starts the process, the runtime loads the framework and the message loop runs. Here the process stops before any of the program's code executes, which is why this course never shows what a window looks like: not because the picture is hard to describe, but because there is no window.
What is installed
dotnet --list-runtimes
Microsoft.AspNetCore.App 10.0.15 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.15 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Two shared frameworks, and neither of them is the one a WinForms program needs. Microsoft.NETCore.App is the base class library and the runtime a console program uses; Microsoft.AspNetCore.App adds a web server. The Desktop framework is a third, separate download on Windows, and it is the only one that carries System.Windows.Forms at run time.
The other half of the picture is a list of what is not installed, and the course names it once instead of repeating it:
- no Windows Desktop runtime, so no WinForms program starts;
- no display and no desktop session, so even a runtime would have nothing to draw on;
- no Visual Studio and no designer, so a form is written and read as code;
- no Windows UI automation and no screenshot tool, so no page shows a picture of a window;
- no gcc, clang or gdb, which matters only to the lessons about Win32 interop and P/Invoke.
What is installed and used by the course: the .NET SDK 10.0.303, the C# compiler behind dotnet build, dotnet format, and the base class library with System.Text.Json, System.Collections.Generic and the rest. Those are enough for the half of a WinForms application that computes.
What this means for the course
The course is split along the line this page draws. A listing that draws a window is built and not run, and the page says which one it is. A listing that computes without a window is built and run, and its output is the real output. The next program is the second kind, and it is here to show the difference on the same page as the failure above:
using System;
var warnings = new[] { "name is empty", "date is not a date" };
foreach (var warning in warnings)
{
Console.WriteLine($"check: {warning}");
}
Console.WriteLine($"{warnings.Length} warnings");
dotnet run
check: name is empty
check: date is not a date
2 warnings
That program has no using System.Windows.Forms; and no window: it is the kind of code that fills a WinForms application's core, and the container runs it exactly as a Windows machine would. The structure part of the course is built on the contrast: the presenter and the validator are run, the form that calls them is only built.
One practical consequence for a reader: a lesson's build command in this course is dotnet build app.csproj, and the run commands appear only on the pages whose program has no window. When a page shows an output under a WinForms listing, the page says in words what the API does, and the output under a headless listing is a real run.
Exercises
- Run the build output with dotnet --list-runtimes in mind and explain which line of the message names the missing framework.
- Change the headless program to print the warnings in reverse order and run it again.
- Add using System.Windows.Forms; to the headless program and read the error the console project gives.
Questions
A new set of questions in a new order every time. Choose one answer for each, then check.
-
What is the exit status of a WinForms program started on this Linux container?
Answer
150
The host program exits with 150 when the requested framework is not installed.
-
Which framework does the message say is missing?
Answer
Microsoft.WindowsDesktop.App, version 10.0.0
The assembly asks for the Desktop framework, which is the one the image does not have.
-
What does dotnet --list-runtimes show on this machine?
Answer
Microsoft.AspNetCore.App and Microsoft.NETCore.App, both 10.0.15
The Desktop framework is a third download and is not in the image.
-
Why does the program not start even if a display were attached?
Answer
The Windows Desktop runtime is still missing
A display is necessary and not sufficient; the framework that draws is not installed.
-
Which part of a WinForms application does the container run?
Answer
The part that computes and draws nothing
Validators, view models and presenters are plain .NET code and run anywhere.
-
What does the first line of the real message ask the reader to do?
Answer
Install or update .NET
It is the host program's message for a missing framework, with a download link.
-
Why is the targeting pack enough for the build?
Answer
The compiler reads reference assemblies, which have the signatures and no implementation
Compilation needs declarations; execution needs the implementation.
-
Which tool of the image is used on WinForms code besides the compiler?
Answer
dotnet format
dotnet format runs against the project and reports formatting and analyzer findings.
-
What does the headless listing with the warnings array show?
Answer
That a program without a window runs and prints here
It is a plain console program, and its two lines are the real output of the run.
-
When a page shows an output under a WinForms listing, what is it?
Answer
The compiler's own output, or documented behaviour described in words
Nothing on the course is invented: it is a real build line or a described API behaviour.
Every listing on this page was built with the .NET SDK 10.0.303 for net10.0-windows against the targeting pack Microsoft.WindowsDesktop.App.Ref 10.0.15 from the offline feed, in a Docker container on Alpine Linux 3.24.3 (x86_64). The programs were built, not run on Linux: WinForms needs Windows.
Article author: Arthur Isaev