Yes, you can precompile using Ngen.exe, however this does not remove the CLR dependence.
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.
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
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.
Why are ngen assemblies slower? ngen is invoked on the target machine, so that should not actually make a difference. Oh, and ngen is not the actual answer to the question.
Ngen is invoked by the developer to precompile the app, not on the target machine. Please read the section on Ngen in CLR Via C#.
Jon, that depends. ngen can be invoked by the installation process on the target machine, and as far as I know this is in fact done for various Microsoft products implemented in .NET.
However, NGen can made into part of the application install process, allowing it to compile to the target machine, I'll edit my post.
EDIT to my comment: you're in fact wrong (and so was I), ngen has to be invoked on the target machine. ngen installs a native image in the machine-local GAC! Precompiling on the developer's machine would be useless.