There is an application. In it, depending on certain parameters, forms from dll are raised, which are dynamically loaded by

Assembly.Load ("Library1.dll");

I need to compile these assemblies into machine images using Ngen

ngen install MyApp.exe

But the problem is that MyApp.exe does not physically refer to these assemblies, and, accordingly, no machine images are created for them. Is there any way around this?

  • Can't you just run ngen on the right libraries? - VladD
  • It is possible, but the image is not created by the library itself, but by those to whom it refers. - Dmitriy

1 answer 1

Understood. If you create a machine image like this

ngen install Library1.dll

Then it is successfully created, but for the application to see this image in c: \ Windows \ assembly \ - this library must be located next to the executable file, even if it is loaded using the Assembly.Load method

  • How did it not work? (This may be important.) - VladD
  • If the library is loaded via Assembly.Load ("Library1.dll"); does not lie in the same directory as the executable file, the Native flag is not included. You can check it using ProcessHacker on the .Net assemblies tab - Dmitriy
  • Understood thanks! - VladD