31

Here is the description of DNX:

The .NET Execution Environment (DNX) is a software development kit (SDK) and runtime environment that has everything you need to build and run .NET applications for Windows, Mac and Linux. It provide a host process, CLR hosting logic and managed entry point discovery. DNX was built for running cross-platform ASP.NET Web applications, but it can run other types of .NET applications, too, such as cross-platform console apps.

Is DNX an alternative to Mono? If not, then what will be the difference?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vano Maisuradze
  • 5,829
  • 6
  • 45
  • 73
  • Tempted to vote as duplicate: http://stackoverflow.com/questions/28379462/coreclr-and-project-mono-relationship-after-microsoft-open-sourced-the-net-roa – nawfal Apr 28 '16 at 12:05

3 Answers3

32

Yes, DNX compares pretty well to Mono's mono.exe. Or for that matter the runtime of other VM languages like Java (java.exe) or Python (python.exe). They all solve the same chicken-and-egg problem, they run on operating systems that don't know beans about the VM. It has to be initialized first, the program's entry point needs to be located and the Main() method needs to be jitted before your program can start running.

One small difference in DNX with these other VMs is that it keeps the CLR and the jitter still in a separate library, coreclr.dll. The other ones are monolithic with all the runtime support code compiled into a single exe. Keeping it monolithic improves cold-start performance. Probably something that will happen with dnx as well, once CoreCLR stabilizes and doesn't have umpteen different beta releases.

This otherwise follows the architecture of .NET on Windows, it is c:\windows\system32\mscoree.dll that bootstraps the CLR. And the CLR and jitter are separate DLLs, clr.dll and clrjit.dll for .NET 4.x. Mscoree uses significant trickery and deceit to make it look like you can start a managed program from a single EXE file. Particularly the trick to create a 64-bit process from a 32-bit EXE file is heroic, it patches internal operating system loader structures to accomplish that feat. This requires Windows itself to be aware that an EXE contains managed code. Trickery that does not translate well to other operating systems like Linux and OSX so they decided for the more conventional way for CoreCLR.


Update: DNX is now deprecated and replaced by DOTNET. Otherwise without invalidating this post content, just easier to use.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
31

Is DNX an alternative to Mono? If not, then what will be the difference?

Mono is an open sourced development platform. Its implementation is based on the CLI specification, such as the platform that is provided by Microsoft. It includes a C# compiler, a runtime, a BCL and something called MCL (Mono Class Library, which is an extensions to the BCL). Mono itself can run on Linux, OS X, BSD and Windows on varying architectures.

DNX is an SDK containing all of the bits needed to build and run an application (including custom utilities such as the dnu which is used to build and package the app), including the CLR (currently it deploys with CoreCLR). This CoreCLR can also be switched with Mono, which means it will be consuming all services of the Mono runtime, compiler, etc.

Mono as opposed to DNX provides the full platform (Runtime, BCL, JIT, etc.). DNX is used at the lowest level as the Native Process which invoked the CoreCLR. DNX would be used for scenarios such as self-host or building and running from the command line.

As @xanatos points out, DNX aspire to be able to ship the runtime with the application, where multiple runtimes will be able to live side by side without interfering each other.

Perhaps this image can clarify:

DNX Diagram

Here is the list which DNX can run on top (x86 showing twice as it is the default):

Active Version           Runtime Architecture Location                           Alias
------ -------           ------- ------------ --------                           -----
  *    1.0.0-beta2-10735 clr     x86          C:\Users\victorhu\.dnx\runtimes default
       1.0.0-dev         clr     x64          C:\Users\victorhu\.dnx\runtimes clr-x64-dev
       1.0.0-dev         clr     x86          C:\Users\victorhu\.dnx\runtimes clr-x86-dev
       1.0.0-dev         coreclr xd64         C:\Users\victorhu\.dnx\runtimes coreclr-x64-dev
       1.0.0-dev         coreclr x86          C:\Users\victorhu\.dnx\runtimes coreclr-x86-dev
       1.0.0-dev         mono                 C:\Users\victorhu\.dnx\runtimes mono-dev

There is an extensive wiki page explaning the DNX structure for more. @Will points out the ASP.NET docs page as well.

Update: 25/02/2016

DNX is now retired in favor of .NET CLI Tools.

Update: 8/6/2020

.NET CLI Tools are now retired in favor of dotnet sdk

Yaron
  • 1,199
  • 1
  • 15
  • 35
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • *on the contrary*: I don't see how the "left part" is opposite to the "right part". Even Mono is decoupled from a specific implementation of an OS... – xanatos May 21 '15 at 13:11
  • 2
    I feel pretty stupid... What is an "execution environment"? What is the difference between Mono and Dnx? Is it simply a glorified installer for .NET/CoreCLR/Mono? Both full .NET and Mono can compile and execute applications. Mono has even a C# interactive shell... – xanatos May 21 '15 at 13:21
  • 3
    Now it is getting clearer :-) From [here](https://github.com/aspnet/DNX) it seems that they want to have side-by-side runtimes that are installed together with the app, instead of having system-wide runtimes... – xanatos May 21 '15 at 14:01
  • @xanatos Your questions made me dig up more information, which changed my answer entirely. Thanks :) – Yuval Itzchakov May 21 '15 at 14:01
  • Where did you get this picture? I have not heard a squeak about helios for a couple of years!... – Andrew Savinykh Aug 19 '15 at 06:42
  • @zespri It was on the documentation site for ASP.NET 5. Not sure where exactly. – Yuval Itzchakov Aug 19 '15 at 06:43
  • I've found this page to be better than the wiki description http://docs.asp.net/en/latest/dnx/overview.html –  Aug 19 '15 at 20:11
  • 1
    @Will I think it'll eventually replace the wiki – Yuval Itzchakov Aug 19 '15 at 20:12
  • @YuvalItzchakov do you have a higher resolution version of this image (the same image is now on aspnet/Home github site in the wiki, same low resolution) - it's the best representation of the 'new world' I've seen to date? As they say, image is woth thousand words etc. :) – rawpower Sep 11 '15 at 09:37
  • @Yuval: DNX will be re-organized in RC2 and shifted from the ASP.Net team to the CLR/CoreFx team (see https://github.com/dotnet/cli). Maybe add a note so later readers are not confused. – Thomas Nov 20 '15 at 09:16
2

DNX is retired, as it said on the repo site. It is better to compare .NET CLI with Mono. .NET CLI is the new project and it doesn't support all .NET libraries cases. It has it own core libraries that are different from the .NET framework.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user854301
  • 5,383
  • 3
  • 28
  • 37