What is the story with these files ending with ni?


If you have done much debugging with .NET 2.0, you have probably come across these files before.  For example, instead of seeing mscorlib.dll in your process, you will see mscorlib_ni.dll.  So what are these files?

.ni images are precompiled managed code files. You take an IL image and run it through a tool called ngen.exe, which produces the .ni image. They’re generated on a client machine and kept in a cache to avoid having to JIT code on the fly.

.ni images do not have symbol files of their own. Instead, they have the debug record info copied from the original IL image and share the IL image’s symbols. There won’t be a PDB specifically for a .ni image, nor will there be much of interest in the PDB (unless it’s a managed C++ image with both native and managed code).

For some additional information on Ngen code and how to debug it, take a look at Mike Stall’s post.  There was also a great article in the MSDN Magazine done by Reid Wilkes back in April of 2005 that you can read here.

kick it on DotNetKicks.com

Comments (7)

  1. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  2. Vikram says:

    Thanks for sharing the interesting stuff…..

  3. Chirag says:

    May I ask why someone would need the ni files?

  4. tomchris says:

    Chirag,

    They allow you to not have to compile the files.  They are already native to the machine.  So it loads faster.

  5. Mojtaba says:

    thanks.but i wonder what ni stands for!

    ngen ???

  6. tomchris says:

    Mojtaba,

    ni stands for Native Image.  Because the file is now compiled for that particular platform.