Reduce startup time of .NET windows form app running off of a networked drive
-
01-07-2019 - |
Question
I have a simple .NET 2.0 windows form app that runs off of a networked drive (e.g. \MyServer\MyShare\app.exe). It's very basic, and only loads the bare minimum .NET libraries. However, it still takes ~6-10 seconds to load. People think something must be wrong that app so small takes so long to load.
Are there any suggestions for improving the startup speed?
Solution
Try out Sysinternals Process Explorer. It has an column of "% time in JIT". If that number is large you could run ngen on your application. If it's not it's likely to be a slow network connection. CodeGuru has a tutorial on usage of ngen.
OTHER TIPS
To speed up load time, you can compile a tiny start application and let that application do the loading of assemblies in runtime from a library outside bin folder.
Determining JIT time for weighing NGEN feasibility is certainly a good starting point. I also would agree with those who look to fudge the load time by using another entry point to then load the assemblies. Often it's the appearance of speed versus actual speed that improves the user experience.
Setup Clickonce for the app so it's deployed to the local machine.
You could cheat like Microsoft Office (and Adobe I think) and add an app in the Startup group that tells the app to load and then immediately unload. That way the DLL's are pre-cached in memory for when the user tries to start the app. Only catch: I'm not completely sure if it works this way with networked files -- and if it doesn't, this might be the cause of the slow start (ie you're always doing a cold start vs a possible warm start if running from the local machine).