什么时候.NET CLR会在程序执行时出现? [英] When and from where the .NET CLR will come into picture while program execution?

查看:84
本文介绍了什么时候.NET CLR会在程序执行时出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Addition.exe 的exe文件,它会提示用户输入两个数字,它会显示总和。

一旦开发人员开发了代码,他就会使用相应的语言编译器将代码编译为IL来构建代码。

我怀疑这是

1)exe文件是否包含这个IL代码,还是包含CLR之后的代码,即本机代码?



现在,用户正在使用这个exe文件并执行程序

2)如果此exe有IL代码,那么CLR将在此处可用机器运行程序,因为用户没有安装任何.net相关软件,他的操作系统可能是Linux,Windows等

3)如果这个exe有本机代码,这不应该'根本就是这种情况,好像它是原生代码一样,根本不会运行



我尝试了什么:



我试过阅读一些文章

I have an exe file named Addition.exe which will prompt user to enter two numbers and it will display the sum.
Once the developer developed the code he will build the code with the respective language compiler compiled it to IL.
My doubt here is
1)does the exe file contains this IL code or will it contains the code after the CLR i.e. Native code?

Now, The user is having this exe file and he executed the program
2) if this exe is having IL code , from where the CLR will be available in this machine to run the program as the user didn't install any .net related software and his OS may be Linux, Windows etc
3)if this exe is having native code, this shouldn't be the case at all, as if it is native code it won't run at all

What I have tried:

I tried by reading some articles

推荐答案

.EXE中有IL。可执行文件中有一个正常的标题,用于加载.NET CLR。应用程序代码不会编译为本机CPU代码。



.NET CLR JIT编译器将加载IL代码,将其编译为运行的CPU的本机代码,缓存该本机代码,然后CPU将执行该操作。



如果运行应用程序的计算机上没有安装相应的.NET Framework,则应用程序将不运行。



.NET Framework 1.0到4.7.2仅适用于Windows。它不适用于其他平台。



对于可以在Windows,Linux和Mac上运行的跨平台应用程序,您必须使用它来构建应用程序.NET Core 2.或更好。仍然需要安装运行时才能运行应用程序。请参阅 .NET Core入门| Microsoft Docs [ ^ ]了解更多信息。
The .EXE has the IL in it. There is a normal "header" in the executable that loads the .NET CLR. The application code is not compiled to native CPU code.

The .NET CLR JIT compiler will load the IL code, compile it to native code for the CPU it's running on, cache that native code, then the CPU will execute that.

If the machine running the application does not have the appropriate .NET Framework installed on it, the application will NOT run.

The .NET Framework 1.0 through 4.7.2 is for Windows only. It will not work on other platforms.

For a cross-platform app that you can run on Windows, Linux, and Mac, you would have to build the application using .NET Core 2. or better. There is still a runtime that has to be installed to run the app. See Get started with .NET Core | Microsoft Docs[^] for more information.


这篇关于什么时候.NET CLR会在程序执行时出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆