Reputation: 474
How does .NET core manages to run the same DLL in multiple OS?
I do now that you have to have .NET core installed in the environment where you want to run your application.
But I don't quite understand the job that .NET core really performs under the hood.
Does it compile to native before the first run or does it interpret each command and execute each command in the underlying system?
Upvotes: 4
Views: 376
Reputation: 3724
.Net core is a JIT compiled VM language. The dlls basically contain a form of bytecode. This is true for all .Net implementations, not just .Net Core. The bytecode is JIT compiled at runtime as needed into native code. [There is also a process called NGEN which allows this bytecode -> native compile to happen ahead of time]. The change from traditional .Net => .Net core is more about removing the OS dependencies of the underlying library systems and runtime.
The JIT (typically) compiles on first use (ie it only has to compile methods that are actually called etc) and keeps the compiled version for reuse. It has at least the option of 'recompiling' hot paths etc with greater optimisation if it feels the need [I don't know if Microsoft's JITs ever actually do this currently].
Futher Reading: https://en.wikipedia.org/wiki/Common_Intermediate_Language#Just-in-time_compilation https://www.telerik.com/blogs/understanding-net-just-in-time-compilation http://tirania.org/blog/archive/2012/Apr-04.html
Upvotes: 3
Reputation: 3054
When we talk about .net core, we are talking about three main feature:
The CoreFx is infact new implementation of BCL which is written in C# and includes all classes that you need to develope your app. CoreFX use #if preprocessor to specify different OS in 100% cases. The .NET Core command-line interface (CLI) is a new cross-platform toolchain for developing .NET applications and the Core Clr is the .net core runtime machine which is responsible for executing your code in different enviroment and written in C++. it use #if preprocessors in 95% cases. but because of producing much many codes in Core-Clr developement, the Core-Clr team seperates Linux and Windows Versions to handle this 5% precents and finally shared runtime that is responsible for loading .net class libraries in linux and mac that is the answer of your question. Hope it helps you.
Upvotes: 0