tags:

views:

51

answers:

3

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?

+2  A: 

Reading the MSDN page for Ngen where it states:

Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

means (to me) that Ngen just does what the JIT compiler does and saves the results. It doesn't say anything about including the .NET runtimes in the binaries.

ChrisF
+4  A: 

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/.

codekaizen
+2  A: 

´NGen´ just compiles your code. It doesn't statically link the entire .NET framework into it.

Mono, however, does have a static compiler and linker that can do this. That's for example how Mono's iPhone support works.

Jörg W Mittag