问题描述
我想在没有 .NET 框架的情况下分发我的 .NET 程序.是否可以将 .NET 程序编译为机器码?
I would like to distribute my .NET programs without the .NET framework. Is it possible to compile a .NET program to machine code?
推荐答案
是的,你可以使用 Ngen.exe 进行预编译,但这并不能消除 CLR 依赖.
Yes, you can precompile using Ngen.exe, however this does not remove the CLR dependence.
您还必须提供 IL 程序集,Ngen 的唯一好处是您的应用程序可以在不调用 JIT 的情况下启动,因此您可以获得真正的快速启动时间.
You must still ship the IL assemblies as well, the only benefit of Ngen is that your application can start without invoking the JIT, so you get a real fast startup time.
根据 CLR 通过 C#:
According to CLR Via C#:
此外,使用预编译的程序集Ngen 通常比 JIT 慢程序集,因为 JIT 编译器可以针对目标机器进行优化(32 位?64 位?特殊寄存器?等),而 NGEN 只会产生一个基线编译.
Also, assemblies precompiled using Ngen are usually slower than JIT'ed assemblies because the JIT compiler can optimize to the targets machine (32-bit? 64-bit? Special registers? etc), while NGEN will just produce a baseline compilation.
对于来自 CLR Via C# 的上述信息存在一些争议,因为有人说您只需要在目标机器上运行 Ngen 作为安装过程的一部分.
There is some debate on the above info from CLR Via C#, as some say that you are required to run Ngen on the target machine only as part of the install process.
这篇关于是否可以将 .NET IL 代码编译为机器代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)