Explain image generator (ngen.exe), DOT NET Programming

Assignment Help:

Image Generator (Ngen.exe)

The Ngen.exe (Native Image Generator) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to disk. When the image is created, .NET runtime will use the image to run the code rather than from the hard disk. The Running of Ngen.exe on an assembly potentially allows the assembly to load & execute faster, since it restores the code and data structures from the native image cache rather than generating them dynamically.

Following are some points to keep on mind for Native Image Generator:-

1) The Native images load faster as compared to MSIL as  JIT compilation and type-safety verification is eliminated.

2) If you are sharing code between process the Ngen.exe increase the performance significantly. As the Native image generated Windows PE file so a single DLL file is shared across applications. On contrast JIT produced code are private to an assembly and can not be shared.

3) Start up time performance improves a lot. We  get considerable gains when applications share component assemblies because after the first application has been started the shared components are already loaded for subsequent applications. If assemblies in the  application must be loaded from hard disk, it does not benefit as much from native images as the hard disk access time shadows everything.

4)The Assemblies in the GAC do not benefit from Native image generator as the loader performs extra validation on the strong named assemblies thus shadowing the benefits of Native Image Generator.

5) If any one of the assemblies changes then Native image should also be updated.

6)You should have the administrative privilege for running the  Ngen.exe.

7)While this may fasten your application start up time as the code is statically compiled but it can be somewhat slower than the code generated dynamically through  the JIT compiler.Thus you need to compare how the whole application performance with Ngen.exe and how iot goes without it.

To run the Ngen.exe, we can use the following command line.

ngen.exe install

This will synchronously precompile the specified assembly and all of its dependencies. And the generated native images are stored in the native image cache.

In the .NET Framework 2.0 there is a service (.NET Runtime Optimization Service) which can precompile managed assemblies at  the background. Assemblies can be schedule  to be precompiled asynchronously by queueing them up with the NGEN Service. We use the following command line.

ngen.exe install /queue:

Assemblies that are critical to your application's start up time should either be precompiled synchronously or by asynchronously with  1. Priority 1 &  2 assemblies are precompiled aggressively while the Priority 3 assemblies are only precompiled during the machine idle-time. Synchronously precompiling your critical assemblies assure you that the native images will be available on prior to the first time your end user launches the application but increases the time taken to run your application's set up program.

You can uninstall an assembly and its all dependencies (if no other assemblies are dependent on them) from the native image cache by running the following command.

ngen.exe uninstall

Native images created using Ngen.exe cannot be deployed; instead they need to be created on the end user's machine. These commands therefore need to be issued as the part of the application's setup program. The .NET Visual Studio can be used to implement this behavior by defining custom actions in a Microsoft Installer (MSI) package.


Related Discussions:- Explain image generator (ngen.exe)

Experienced outlook developer, About us in a nutshell: We are a young start...

About us in a nutshell: We are a young start-up that trade a refreshing product in the field of enterprise software and develops with the latest technologies. We love to partner wi

Sequence in which asp.net events are processed, What' is the sequence in wh...

What' is the sequence in which ASP.NET events are processed? The sequence in which the ASP.NET events occur are as folows :- 1.     Page_Init. 2.     Page_Load. 3.

Explain custom authentication, Custom authentication: If we don't need ...

Custom authentication: If we don't need ASP.NET to perform any authentication, we can set the authentication mode to none. The reason behind this decision could be: We don't

I need mt4 programmer, I need mt4 programmer Project Description: I'm...

I need mt4 programmer Project Description: I'm seeking a professional programmer to teach me MQL I have few years experience in manual trading but totally NONE in MT4 / EA

Perform arithmetic operation on floating values in c#, Perform Arithmetic o...

Perform Arithmetic operations on Floating Values - C# Program Hello, I've been trying so many codes for this but those codes didn't work well. Please write the code for Perfor

I am looking for an icenium developer, ASP.net developer for a mobile proje...

ASP.net developer for a mobile project I am looking for an Icenium developer using the Visual Studio extension and jquery. The application will incorporate with an already wr

Client side validation, If client side validation is enabled in your Web pa...

If client side validation is enabled in your Web page, does that mean server side code is not run Whenever the client side validation is enabled server emit's JavaScript code f

Unicode, What is Unicode? In order to understand the concept of Unicode...

What is Unicode? In order to understand the concept of Unicode we require  to move a little back and understand the ANSI code. The ASCII (ask key) stands for American Standard

List the new features added in .net framework 4.0, List the new features ad...

List the new features added in .NET Framework 4.0. The following are the latest features of .NET Framework 4.0:     Improved Application Compatibility and Deployment Support

Pareto principle, What is pareto principle? The Pareto principle also p...

What is pareto principle? The Pareto principle also paraphrased as 80/20 principle is simple effective problem tackling way in the management. It says that 20% of your problems

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd