Is it possible to force loading all assemblies before they are used?

Hello

I'm using web services provided by a cassini derivate.

The web service calls are quite slowly because used assembly are not loaded as long as the provided classes are not used.

Is there any way to force that all assemblies on which my application depends are loaded into memory at the application start

Caution: The provided web services are in own AppDomains. If I may force preloading all assemblies will the assemblies of the provided web services also be loaded

Thanks a lot for helpful answers

Best regards

Hurz


Answer this question

Is it possible to force loading all assemblies before they are used?

  • Fritz Bilda

    If your web service is slow then I very much doubt it is because it hasn't loaded the assemblies.  Loading all the assemblies (and you'd probably want them to be JIT'ed too) will dramatically slow down your application's startup.  And since it is a web service you would have to go hit your web service before anybody else otherwise some poor customer is going to be waiting a really long time for all the assemblies to load.  Furthermore since a web service can be unloaded and reloaded at will by ASP.NET you'll really have problems keeping up with it.

    When .NET loads it delay loads the assemblies (just like delay-loading in C++) for speed purposes.  As you hit a class and/or method the first time it will go through the JIT process as well.  This isn't free but the cost is probably negliable compared to anything you are doing in your web service.  And once it is done it is done.

    The slowness in your app is probably the overhead of making a web service call.  Web service calls are expensive because they go through the ASP.NET pipeline.  Not much you can do there.  I would recommend that you profile your app to see exactly where the time is being spent.  It possibly could be a network, bandwidth or IIS issue.

    Back to your original question however you could NGen the web service to produce a native image.  I think it'll still delay-load but you won't have the overhead of JITting.

    Michael Taylor - 10/28/05

  • Larantz

    If you are working on .NET 1.1, note that there is a caching issue for ASP.NET that was solved in .NET 2.0. It causes the response of Web services and remoting components hosted in ASP.NET to have a slow response if the size of data is large.

    As TaylorMichaelL suggested, I recommend you to use a profiler to know exactly the cause of the delay in your application.


  • Is it possible to force loading all assemblies before they are used?