NGEN and resolving assemblies

  • Thread starter Thread starter Wol
  • Start date Start date
W

Wol

I have two assemblies, A.dll and B.dll.

A.dll contains two methods. One method, UsesB, uses a type from B.dll
whereas the other, DoesNotUseB, does not.

To cache a native image of A.dll with both methods precompiled, I believe I
can do

ngen A.dll B.dll

I think I could also do

ngen B.dll
ngen A.dll



Will just

ngen A.dll

also produce a native image of A.dll with both methods precompiled, or will
it precompile only the method that does *not* use types from B.dll? (or will
it precompile neither?)

In other words, does

ngen A.dll

resolve B.dll and use the metadata in B.dll to work out the physical layout
of the types in B.dll so that it can generate native code for A.UsesB(), or
does it need B.dll to be in the native image cache already, or do I actually
have to supply both dlls to ngen at the same time, ie

ngen A.dll B.dll

TIA
 
"ngen A.dll" is not the same as "ngen A.dll B.dll". The latter will
pre-compile both assemblies.

"ngen A.dll" will load B automatically (through the normal assembly probing
logic), and compile both methods.

To prove it, run "ntsd ngen A.dll", you will see b.dll in the loaded module
list, assuming b.dll can be found by ngen.
 
The ngen image of A will use indirections (similar to IATs in the unmanaged
world) to access data from B.dll. (In the next version, these indirections
can be removed).

We will resolve the physical layout of types in B. So if B.dll changes, you
need to re-ngen A.dll as the old ngen image is/may be invalid and will not
be used anymore.
 
Back
Top