(1)       由原程序编译成程序集。

我们写完代码后,编译出来的DLL文件或EXE文件,该文件称为程序集,程序集包括MSIL以及元数据(元数据中包含类、属性以及类之间关系等数据)。不管是VB.NET还是C#,最后生成的程序集都包括MSIL以及元数据。

 

(2)       MSIL编译成本地代码。

使用本机映像生成器(NGEN.exe)工具将MSIL编译成可以直接在本地执行的本地代码,并保存到本地映像中。

 

(3)       运行程序时,内部都干了些什么

当我们每次运行.net程序时,CLR都会即时对MSIL进行编译成本地代码,并执行。实际上,我们也可以使用NGen.exe工具将我们的程序集生成本地代码,这样可以一定程度上提高程序的启动速度。

 

(4)       实践例子

1、 首先,我们写一个简单的程序,并生成程序集,见下图:


2、 打开.net自带的反编译工具ILDASM,如下图:


 

3、 我们再打开我们生成的程序集,看看里面的中间语言代码(MSIL),如下图:


 看到了吗,图中的代码就是程序的中间代码。

4、 现在,让我们手工把它编译成本地代码,打开.net的命令行工具,并使用NGen.exe工具将我们的程序集编译成本地代码,输入命令,ngen + 程序集的绝对路径,如下图:


看到没有,已经编译成本地代码映像了。

5、 最后,让我们看看已经生成的本地代码映像,输入ngen /show StudyMSIL,如下图:


^_^ 看到了吗,这就是我们的本地代码映像文件

http://zzdx.ycnews.cn/
http://zzdx.ycnews.cn/cf/77.html
http://zzdx.ycnews.cn/cnrtx/
http://zzdx.ycnews.cn/cnrtx/119.html
http://zzdx.ycnews.cn/cnrtx/120.html
http://zzdx.ycnews.cn/cnrtx/65.html
http://zzdx.ycnews.cn/cnrtx/66.html
http://zzdx.ycnews.cn/cnrtx/67.html
http://zzdx.ycnews.cn/cnrtx/68.html
http://zzdx.ycnews.cn/cnrtx/69.html
http://zzdx.ycnews.cn/cnrtx/70.html
http://zzdx.ycnews.cn/dxal/
http://zzdx.ycnews.cn/dxal/106.html
http://zzdx.ycnews.cn/dxal/107.html
http://zzdx.ycnews.cn/dxal/108.html
http://zzdx.ycnews.cn/dxal/109.html
http://zzdx.ycnews.cn/dxal/116.html
http://zzdx.ycnews.cn/dxal/23.html
http://zzdx.ycnews.cn/dxal/24.html
http://zzdx.ycnews.cn/dxal/25.html
http://zzdx.ycnews.cn/dxal/26.html
http://zzdx.ycnews.cn/dxal/27.html
http://zzdx.ycnews.cn/dxal/28.html
http://zzdx.ycnews.cn/dxal/29.html
http://zzdx.ycnews.cn/dxal/30.html
http://zzdx.ycnews.cn/dxbfz/38.html
http://zzdx.ycnews.cn/dxbk/
http://zzdx.ycnews.cn/dxby/35.html
http://zzdx.ycnews.cn/dxjj/37.html
http://zzdx.ycnews.cn/dxlx/
http://zzdx.ycnews.cn/dxrq/
http://zzdx.ycnews.cn/dxwh/22.html
http://zzdx.ycnews.cn/dxxl/32.html
http://zzdx.ycnews.cn/dxyf/21.html
http://zzdx.ycnews.cn/dxyf/33.html
http://zzdx.ycnews.cn/dxys/31.html
http://zzdx.ycnews.cn/dxzd/111.html
http://zzdx.ycnews.cn/dxzd/36.html
http://zzdx.ycnews.cn/dxzj/
http://zzdx.ycnews.cn/dxzj/124.html
http://zzdx.ycnews.cn/dxzj/125.html
http://zzdx.ycnews.cn/dxzj/126.html
http://zzdx.ycnews.cn/dxzl/
http://zzdx.ycnews.cn/dxzl/110.html
http://zzdx.ycnews.cn/dxzl/112.html
http://zzdx.ycnews.cn/dxzz/34.html
http://zzdx.ycnews.cn/etdx/
http://zzdx.ycnews.cn/etdx/114.html
http://zzdx.ycnews.cn/etdx/115.html
http://zzdx.ycnews.cn/etdx/39.html
http://zzdx.ycnews.cn/etdx/40.html
http://zzdx.ycnews.cn/etdx/41.html
http://zzdx.ycnews.cn/etdx/42.html
http://zzdx.ycnews.cn/etdx/43.html
http://zzdx.ycnews.cn/etdx/44.html
http://zzdx.ycnews.cn/jfxdx/72.html
http://zzdx.ycnews.cn/jj/76.html
http://zzdx.ycnews.cn/lnrdx/
http://zzdx.ycnews.cn/lnrdx/59.html
http://zzdx.ycnews.cn/lnrdx/60.html
http://zzdx.ycnews.cn/lnrdx/61.html
http://zzdx.ycnews.cn/lnrdx/62.html
http://zzdx.ycnews.cn/lnrdx/63.html
http://zzdx.ycnews.cn/lnrdx/64.html
http://zzdx.ycnews.cn/lylx/
http://zzdx.ycnews.cn/nxdx/
http://zzdx.ycnews.cn/nxdx/118.html
http://zzdx.ycnews.cn/nxdx/51.html
http://zzdx.ycnews.cn/nxdx/52.html
http://zzdx.ycnews.cn/nxdx/53.html
http://zzdx.ycnews.cn/nxdx/56.html
http://zzdx.ycnews.cn/nxdx/57.html
http://zzdx.ycnews.cn/nxdx/58.html
http://zzdx.ycnews.cn/qsndx/
http://zzdx.ycnews.cn/qsndx/113.html
http://zzdx.ycnews.cn/qsndx/45.html
http://zzdx.ycnews.cn/qsndx/46.html
http://zzdx.ycnews.cn/qsndx/47.html
http://zzdx.ycnews.cn/qsndx/48.html
http://zzdx.ycnews.cn/qsndx/49.html
http://zzdx.ycnews.cn/qsndx/50.html
http://zzdx.ycnews.cn/swt/
http://zzdx.ycnews.cn/swt/qq.html
http://zzdx.ycnews.cn/swt/tel.html
http://zzdx.ycnews.cn/xslw/
http://zzdx.ycnews.cn/xslw/100.html
http://zzdx.ycnews.cn/xslw/101.html
http://zzdx.ycnews.cn/xslw/102.html
http://zzdx.ycnews.cn/xslw/71.html
http://zzdx.ycnews.cn/xslw/99.html
http://zzdx.ycnews.cn/ydf/74.html
http://zzdx.ycnews.cn/yfxdx/73.html
http://zzdx.ycnews.cn/yjf/75.html
http://zzdx.ycnews.cn/yygy/
http://zzdx.ycnews.cn/yygy/86.html
http://zzdx.ycnews.cn/yygy/87.html
http://zzdx.ycnews.cn/yyjj/
http://zzdx.ycnews.cn/yyjj/85.html
http://zzdx.ycnews.cn/yyxw/
http://zzdx.ycnews.cn/yyxw/103.html
http://zzdx.ycnews.cn/yyxw/104.html
http://zzdx.ycnews.cn/yyxw/105.html
http://zzdx.ycnews.cn/yyxw/83.html
http://zzdx.ycnews.cn/yyxw/84.html
http://zzdx.ycnews.cn/zjjz/117.html
http://zzdx.ycnews.cn/zjjz/88.html
http://zzdx.ycnews.cn/zjjz/91.html
http://zzdx.ycnews.cn/zjjz/93.html
http://zzdx.ycnews.cn/zjwd/
http://zzdx.ycnews.cn/zjwd/90.html
http://zzdx.ycnews.cn/zjwd/92.html
http://zzdx.ycnews.cn/zjwd/94.html

Copyright © 2024 火之光
Powered by .NET 8.0 on Kubernetes