NGen usage RRS feed

  • Question

  • I have used Ngen i am still worries whether i followed the proper steps.I followed the below steps,
    1. in \bin directory i kept all my dlls.
    2. i used folllowing command,
        ngen queue pause
        ngen install mytest.dll /queue
        ngen install mytest1.dll /queue
        ngen install mytest.exe /queue
        ngen update /queue
        ngen executequeueditems
        ngen queue continue
    3. after that i executed the mytest.exe.
    i have done only these steps.other than that i havent used anything.
    are my steps are correct?

     Do we should not use NGen for the dll containing "assembly.loadfrom() " statement
    Do we should not use NGen for the dll which is loaded by "assembly.loadfrom() " function present in someother dll.

    Since i am using Composite UI application block. here all my modules are loaded by the moduleloader service.Is it good to use NGen for CAB?

    please help me in this..

    thanks in advance.

    Friday, April 6, 2007 12:58 PM


All replies

  • Your usage appears correct.


    NGEN is safe to use on any valid .NET DLL.  The code inside is not important.


    Also, NGEN is never required.  Most applications work perfectly fine without it, and not using NGEN can reduce deployment complexity.


    -Ryan / Kardax

    Friday, April 6, 2007 4:11 PM
  • Singam,


    I've replied to your question about the series of NGen steps to be followed, on your original thread. In order to check that you are indeed loading the NGen images during execution, FusLogVw.exe (a tool that ships with the .Net Framework 2.0 SDK) will help.


    This snippet from the MSDN documentation for NGen also goes over this -


    To confirm that native images are being used by your application, you can use the Assembly Binding Log Viewer (Fuslogvw.exe). Select Native Images in the Log Categories box on the binding log viewer window. Fuslogvw.exe provides information about why a native image was rejected.

    You can use the JitCompilationStart managed debugging assistant (MDA) to determine when the JIT compiler starts to compile a function.




    ~Pracheeti Nagarkar

    Microsoft, NGen Team

    Friday, April 6, 2007 8:58 PM
  • thanks Pracheeti Nagarkar.
    But CAB framework uses Assembly.loadfrom() API to load all the assemblies specified in the ProfileCatalog.xml.
    It means cant we use NGen for CAB application?
    Actually i need to improve the startup time of CAB application.How to improve?

    thanks in advance.
    Uvaraj T

    Sunday, April 8, 2007 10:52 AM
  • Hi singam,


    Assume CAB is using Assembly.LoadFrom(), NGEN cannot be applied.

    Generally, Assembly.LoadFrom() does not work with NGen images:


    Native Image Generator (Ngen.exe) 



    Do not use the System.Reflection.Assembly.LoadFrom method with native images. An image loaded with this method cannot be used by other assemblies in the execution context.


    Assemblies in LoadFrom context can’t be domain neutral, and can’t use NGEN




    To improve the application performance, It's suggested that you should profile your application by .Net CLR Profiler tool 


    How To: Use .Net CLR Profiler



    Monday, April 9, 2007 10:31 AM