.net-6.0.net-runtime

Getting "You must install .NET Desktop Runtime 6.0.3 (x86)" with correct runtime installed


An application built targeting .NET 6 is showing the following message when double-clicking the EXE in Windows Explorer:

To run this application, you must install .NET Desktop Runtime 6.0.3 (x86)

Install .NET Desktop Runtime 6.0.3 (x86)

This runtime (6.0.3 x86) is installed on the machine though. I have confirmed this using the dotnet --info command:

dotnet --info output

I also tried 6.0.4 runtimes but those didn't work either.

This happens on a Windows 10 machine but I also tested this on Windows 11:

  1. Downloaded the Windows 11 dev virtual machine in Hyper-V.
  2. Removed .NET 6 with Visual Studio Installer.
  3. Installed windowsdesktop-runtime-6.0.3-win-x86 from Microsoft's Download .NET 6 page.

The same happens with the (Windows 10) MSIX Packaging Tool Environment machine you can download in Hyper-V. In this .NET 6 is not installed. Same result after installing windowsdesktop-runtime-6.0.3-win-x86.

Setting the Target CPU option (in Project Properties > Compile) to Any CPU yields a similar result, asking for the .NET Desktop Runtime x64 version which I have also installed.


Solution

  • The Build process generates:

    1. assembly_name.deps
    2. assembly_name.pdb
    3. assembly_name.runtimeconfig.json

    I was able to launch the application by including the runtimeconfig.json file.

    With .NET Framework applications, it was possible to simply copy the EXE and DLLs but it seems like this is not possible with .NET Core applications.

    A better approach is to use the Publish feature which can properly bundle all the necessary files into a single EXE for distribution.