I often get asked how to speed up the .NET applications startup times and my answer is often to try NGEN which pre-compiles assemblies at install time instead of when application is run. Here is a nice guidelines from CLR team at Microsoft that outlines when to actually do that. In short NGEN can help you if:

  • You have a large application that has lots of managed code that gets fetched and/or ran at startup. When such application is run the Just-in-time compiler goes and compiles all Intermediate Language code first which of course takes certain amount of time. More code equals longer JIT times resulting in startup delays. Eliminating this steps by using NGEN will help with both cold and warm application startup times.
  • You have framework, library or other reusable components. Code that is produced by JIT cannot be shared across multiple processes, but the code produced by NGEN can. When multiple applications are using the same library and component this results in smaller memory footprint and faster loading times since component once loaded is shared between the applications.
  • Your application is expected to be running under Terminal Services. This is closely related to previous point since code will be reused in multiple processes.

You should not use NGEN for smaller applications, generally there is no benefit in doing so.

You can read full post here.

Here is also good information on how to integrate NGEN into the setup.

MSDN Magazine also has good article on how to squeeze maximum out of NGEN.

Professional looking applications made easy with DotNetBar for WinForms, Silverlight and WPF User Interface components. Click here to find out more.

Related posts:

  1. 12 Tips To Speed-up Your Windows Forms Applications
  2. BitmapImage.ImageSource image loading – correct syntax for URI
  3. Loading XAML ResourceDictionary from code
  4. Great WPF Applications
  5. 2 Things You Can Do Today To Improve User Interface In Your Applications