Tuesday, October 16, 2007

Get .NET apps to launch faster using ngen.exe


A .NET application isn't natively machine code. The code is in the Microsoft Intermediary Language (MSIL). At runtime the program uses the just-in-time (JIT) compiler to produce machine code.

There is a delay before your application launches or when certain subroutines in your application launch for the first time. This is the JIT compiling it to machine code. The code isn't permanently compiled and is lost when the application closes.

I added the framework directory to my path. This is a non-standard install of XP so your path may be different. To change the path on XP you can right click MY COMPUTER then PROPERTIES then ADVANCED then ENVIRONMENT VARIABLES


You can create a compiled version of your EXE simply by running the following.
ngen install

From Namratha Shah's post:

Looking at a few options of Ngen.exe

To create a native assembly

You can also create a native image of one or more assemblies at the same time

To view all the assemblies in the native cache use the/show option

ngen /show
To delete an assembly from the cache
ngen /delete 

No comments: