The Ngen Utility

You’ve heard about precompiling assemblies and the Ngen utility. When should you use it?

Use Ngen.exe to precompile Windows Forms applications and Windows Forms Control DLLs. As a general rule, don’t use the utility for any other application type.

Why would you want to use this neat little utility? In short, because precompiling these assemblies significantly speed up their loading time. In addition, precompiled assemblies run faster on machines with less RAM, and that just isn’t possible with JIT-compiled assemblies. So, then, why would you not want to use Ngen and precompile your assemblies? Well, that’s because Ngen-compiled assemblies aren’t as optimized as JIT-compiled ones, and they can run slower. The difference is between load/start and run times. That being said, each application reacts differently to Ngen compilation. You can always test out a Ngen-compiled version and see if it loads more rapidly and runs fast enough for your needs. Like Gacutil, you can run Ngen as a post-build event or create a custom macro to execute it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s