ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

.NET Core - Code Execution

2021-08-06 22:35:03  阅读:320  来源: 互联网

标签:Core code language Code MSIL NET execution


In this chapter, we will understand the execution process of .NET Core and compare it with the .NET Framework. The managed execution process includes the following steps.

  • Choosing a compiler
  • Compiling your code to MSIL
  • Compiling MSIL to native code
  • Running code

Code Execution

Choosing a Compiler

  • It is a multi-language execution environment, the runtime supports a wide variety of data types and language features.

  • To obtain the benefits provided by the common language runtime, you must use one or more language compilers that target the runtime.

Compiling your code to MSIL

  • Compiling translates your source code into Microsoft Intermediate Language (MSIL) and generates the required metadata.

  • Metadata describes the types in your code, including the definition of each type, the signatures of each type's members, the members that your code references, and other data that the runtime uses at execution time.

  • The runtime locates and extracts the metadata from the file as well as from framework class libraries (FCL) as needed during execution.

Compiling MSIL to Native Code

  • At execution time, a just-in-time (JIT) compiler translates the MSIL into native code.

  • During this compilation, code must pass a verification process that examines the MSIL and metadata to find out whether the code can be determined to be type safe.

Running Code

  • The common language runtime provides the infrastructure that enables the execution to take place and services that can be used during execution.

  • During execution, managed code receives services such as garbage collection, security, interoperability with unmanaged code, cross-language debugging support, and enhanced deployment and versioning support.

.NET Core Code Execution Process

Now let’s relate how code executes with .NET Core as compared to .NET Framework. In .NET Core there are many replacements of these components that are the part of the .NET Framework.

.NET Core Code Execution

  • In .NET Core now we have a new series of compilers, like we have Roslyn for C# and VB.

  • You can also make use of the new F# 4.1 compiler if you want to use F# with .NET Core.

  • Actually these tools are different and we can use Roslyn with .NET Framework as well if we are using C# 6 or later, because C# compiler can only support up to C# 5.

  • In .NET Core, we don’t have a framework class libraries (FCL), so a different set of libraries are used and we now have CoreFx.

  • CoreFx is the reimplementation of the class libraries for .NET Core.

  • We also have a new run time with .NET Core known as CoreCLR and leverages a JIT Compiler.

  • Now the question is why do we have the reimplementation of all these components that we already have in .NET framework.

  • So the answer is the same as why Microsoft implemented .NET Core

标签:Core,code,language,Code,MSIL,NET,execution
来源: https://www.cnblogs.com/Griffin/p/15110553.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有