.net-core - CLR 与核心 CLR

标签 .net-core clr coreclr

我了解当前状态的 CLR 绑定(bind)到 Windows 操作系统,并通过在内部使用 Win32 API 提供各种服务。

由于 .NET Core 是独立于平台的,这基本上意味着相同的 IL 代码可以在不同的操作系统上运行。 CoreCLR 操作系统是特定的吗?还是编写 CoreCLR 代码以根据当前执行环境/操作系统采用不同的执行路径?

最佳答案

来自 discussion in coreclr repository :

As far as I am aware the CLR in this repo [coreclr] is identical to the CLR in full .NET and the only differences are in the available API set in corefx.

... but seems like there is at least C++/CLI that is missing...



要回答其他一些问题:

Since .NET Core is platform independent, this basically implies the same IL code can run on different OS



是的。 IL 是一种自定义的“语言”。您可以为它编写一个可以在任何平台上运行的解释器/运行时。对于其他语言中的其他中间表示也是如此,包括 java 字节码、llvm ir、python 字节码等。

Is CoreCLR OS specific? Or is CoreCLR code written to take different execution paths depending upon current execution environment/OS ?



这是一个混合体。特定版本的 coreclr 只能在一个操作系统上运行,因为它已被编译为使用该操作系统的功能(包括特定于操作系统的编译器、链接到正确的特定于操作系统的库以及运行特定于处理该操作系统的代码)。 CoreCLR 中还有一个平台抽象层,因此开发人员可以针对一个 API 进行编码 - 基于 Win32 API - PAL 层将其转换为 Linux 和 Mac 上的正确系统调用。正如@HansPassant 在评论中指出的那样,有大量的#ifdefs - 在CoreCLR 的 native 端和托管端。

关于.net-core - CLR 与核心 CLR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48908739/

相关文章:

asp.net-core - .Net 核心 2.2 的 .Net 标准版本

c# - 创建目录后.NET Core控制台应用程序出现UnauthorizedAccessException

c# - 如何为dotnet应用创建docker镜像?

.net - 单个 .NET 程序集针对两个不同的 CLR?

c# - 检查 double.ToString()

c# - 在 asp.net 核心中处理异常?

c# - Serilog - 单独的信息文件,使用 appsetting.json 的异常(exception)

.net - 使用 useLegacyV2RuntimeActivationPolicy 和多个 supportedRuntimes 有什么区别

linux - Linux 上的 ASP.NET Core 1.0/Kestrel 未创建 unix 套接字

.net - Asp.Net Core RC2 与 Microsoft.Owin