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.
- Native images load faster than MSIL because they eliminate the need for many startup activities, such as JIT compilation and type-safety verification.
- Native images require a smaller initial working set because there is no need for the JIT compiler.
- Native images enable code sharing between processes.
- Native images require more hard disk space than MSIL assemblies and may require considerable time to generate.
- Native images must be maintained.
- Images need to be regenerated when the original assembly or one of its dependencies is serviced.
- A single assembly may need multiple native images for use in different applications or different scenarios. For example, the configuration information in two applications might result in different binding decisions for the same dependent assembly.
- Native images must be generated by an administrator; that is, from a Windows account in the Administrators group.
- Large applications generally benefit from compilation to native images. Small applications generally do not benefit.
- For long-running applications, run-time JIT compilation performs slightly better than native images. (Hard binding can mitigate this performance difference to some degree.)