是否有可能编译.NET IL code到机code?

问题描述:

我想没有.NET框架分发我的.NET程序。是否有可能一个.NET程序被编译成机器code?

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依赖precompile。

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#:

此外,使用组件precompiled   NGEN通常比JIT'ed慢   组件因为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通过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.