Search code examples
.netngen

Is ngen used to compile .NET code into an binary that will not require .NET framework to be installed when running the code?


I read the following paragraph on Wikipedia article about the CLR:

Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime by using the Native Image Generator (NGEN). This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.

Does this mean that I can take any .NET program and compile it to a binary that will then be able to run on machine that doesnt have the .NET framework installed?


Solution

  • No.

    It means that you won't need to run the JIT (Just-In-Time) compiler when you run the code, since it is already converted to machine code by NGen. The resulting binaries still have dependencies on the .Net framework, and this must be installed separately on the machine.

    There are tools which package the .Net framework assemblies and include them in your binaries in a way which the .Net framework is not needed. Check out http://www.xenocode.com/. VMWare bought a tool called Thinstall, which I think can also do this: http://www.vmware.com/products/thinapp/.