What is Native Image Generator (Ngen.exe)?
Native Image Generator
The Native Image Generator (Ngen.exe) generates a native binary image for the current operating systems. It is stored in a native image cache on the local computer. It allows the assembly to load and execute faster, because it restores code and data structures from the native image cache rather than generating them dynamically.
Using native images typically benefits applications by improving their startup times. After the Native Image is generated, .NET runtime will use the image to run the code rather than from the hard disk. So when an assembly is executed, the CLR first looks for a native image based on the above factors, if not found, it reverts to JIT runtime compilation. When compared to Native Image, MSIL code is loading slow because of JIT compilation and type-safety verification.
The above command generates a native image for MyApp.exe, located in the current directory, and installs the image in the native image cache.
The above command generates a native image for MyApp.exe with the specified path.
The above command uninstalls the MyDll.dll from the previous example.
- Difference between NameSpace and Assembly
- Execution process for managed code
- What is an Asssembly Qualified Name
- How to Assembly versioning
- Add and remove an assembly from GAC
- How to force Garbage Collection
- Difference between CType and DirectCast
- Obsolete or Deprecated in NET Framework
- What is lazy initialization
- Difference between Clone and Copy
- Difference between Finalize() and Dispose()
- Difference between static and constant