1

I ran dotnet.exe in a Ubuntu WSL2 instance, and it surprisingly ran. This is a Windows program, that just ran on an Ubuntu instance. How is this possible? Could someone provide a link to the documentation that explains this behaviour?

enter image description here

The tool runs from WSL2:

❯ dotnet.exe --list-runtimes
Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
  • What happens when you actually try to use the tool though? I imagine it wouldn't work as soon as any libraries or syscalls are invoked. – wxz Mar 15 '21 at 19:25
  • @wxz It runs fine (see edit) – Sridhar Ratnakumar Mar 15 '21 at 19:47
  • 1
    Maybe [this](https://superuser.com/questions/1525506/why-is-windows-subsystem-for-linux-able-to-run-windows-exe-programs) explains it? – wxz Mar 15 '21 at 19:49
  • 1
    Also covered [here](https://stackoverflow.com/a/38920711/11810933) on Stack Overflow. Short answer - `binfmt_misc` (also see [here](https://en.wikipedia.org/wiki/Binfmt_misc)). And the official Microsoft [WSL docs on interop](https://learn.microsoft.com/en-us/windows/wsl/interop). – NotTheDr01ds Mar 15 '21 at 20:45

0 Answers0