The title says it all. I was hoping somebody could explain to me what .NET Native brings to the table that we didn't already have with Ngen.exe.
What does NGen exe mean?
The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. 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.
What is Microsoft NET Framework NGen?
NGen refers to the process of precompiling Microsoft® intermediate language (MSIL) executables into machine code prior to execution time.
Where is NGen exe located?
The ngen.exe file is located in a subfolder of C:\Windows (for example C:\Windows\Microsoft.NET\Framework\v4. 0.30319\).
How do I get rid of NGen exe?
Open the Start menu, then click Settings. Click System on the Settings menu, then select Apps & features on the left pane. Select an app you wish to uninstall, then click Uninstall.
What is the difference between Ngen and NET Native?
Runtime dependency- NGEN uses the full desktop CLR, .NET Native uses a refactored runtime (mrt100_app.dll) which is application local. The .NET Native runtime has been refactored to move most functionality out of the application and into the code generation tool chain.
What happens when Ngen Exe fails to generate a native image?
If Ngen.exe encounters any methods in an assembly that it cannot generate, it excludes them from the native image. When the runtime executes this assembly, it reverts to JIT compilation for the methods that were not included in the native image.
What is the difference between Ngen and runtime?
The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly. Ngen.exe compiles native images for assemblies that target the .NET Framework only.
What is the difference between Ngen and JIT?
IL Fallback- NGEN images contain both the native code and MSIL for an assembly (among other data structures). If something occurs at runtime which causes the CLR to need native code that it cannot find in the NGEN image, it can fall back to JITing. In .NET Native's current developer previews, only native code is present in the native image.
You can think of .NET Native as an evolution of the NGen technology that the desktop CLR uses. There's a few major ways that .NET Native and NGEN differ -
- Runtime dependency - NGEN uses the full desktop CLR, .NET Native uses a refactored runtime (mrt100_app.dll) which is application local. The .NET Native runtime has been refactored to move most functionality out of the application and into the code generation tool chain. This makes it much smaller, more pay for play, and (hopefully) more debuggable at runtime. A .NET Native application is also self-contained, which is a useful property to have for an application.
- Native image dependencies - an NGEN image is tightly bound to both the CLR that it runs against and the NGEN image of its dependent assemblies. This, for example, causes nearly all NGEN images to need to be regenerated when a bug fix is made to mscorlib.dll.
- Compilation Location - the aim for .NET Native is to have the native code be generated in the app store. NGEN generates native code on the end user device. You can certainly imagine that for certain classes of devices (ie phones, tablets) you'd much rather not waste end-user battery life generating code. Compiling in the store also allows .NET Native to spend more time compiling, therefore allowing it to apply more optimizations than NGEN can afford.
- Code generator - NGEN uses the JIT compiler to generate code, .NET Native uses the Visual C++ compiler's back end, which enables us to apply optimizations such as auto-vectorization that are too expensive to apply in the JIT case
- Whole program analysis - NGEN generates code for a single assembly at a time, which allows an NGEN image to be used in multiple application contexts. .NET Native generates code for an entire application package, which allows it to apply a broader set of optimizations (for instance, entirely throwing away code that's not ever used at runtime). This is coupled with a refactored framework which enables these optimizations to kick in as much as possible.
- IL Fallback - NGEN images contain both the native code and MSIL for an assembly (among other data structures). If something occurs at runtime which causes the CLR to need native code that it cannot find in the NGEN image, it can fall back to JITing. In .NET Native's current developer previews, only native code is present in the native image. This means that if the code isn't present in the image, it will never execute at runtime.