Sharing NGEN image in Multi-Domain Host

To reuse the same NGEN image of an assembly for every domain in a multi-domain environment, the assembly has to be loaded as domain neutral.

To enable domain neutral assemblies, the host must enable domain sharing when it starts CLR.

This is all discussed in my previous blog Domain Neutral Assemblies. Specifically,


There are two ways for a host to specify this hint. One way is through hosting API CorBindToRuntimeEx. Another way is decorating your Main method with LoaderOptimizationAttribute.


If the host did not enable domain sharing when it started CLR, NGEN image will be used in the first appdomain. The other appdomains will JIT compile the assemblies.

Comments (2)

  1. Renugopal says:

    How the static Data structure are maintained across Mutiple application Domain.if an Assembly loaded by Domain neutral.

  2. Renugopal says:

    what is NGEN Image of an Assembly?

    u mean natively jitted code of an Assembly.