It’s a little difficult for me to display the progress of assemblies loaded in AppDomain.CurrentDomain.
What I want to do is to display a splash screen that has a progress bar, I want to update this progress bar as each assembly is loaded into memory in AppDomain. Thus, users will have a visual indicator of the progress of launching the application.
I don’t care that the assemblies are loaded before the Splash screen is displayed, which is actually a standard WPF window with a progress bar. When the Splash screen is loaded, I would like to tell the assemblies when they are loaded. I do not manually download these assemblies.
So far, I have been handling the Startup event in App.xaml with the following markup:
Startup="Application_Startup"
The appropriate code to run is as follows:
private void Application_Startup(object sender, StartupEventArgs e) { SplashScreen.Show<SplashScreen>(); AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad; } void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) { SplashScreen.CallSplashScreenMethod<SplashScreen>(x => x.Text(args.LoadedAssembly.GetName().Name)); }
This works as I expect, the splash screen is displayed and all the assemblies that will be loaded the moment the splash screen is displayed are displayed on the screen without any problems.

The problem here is that I don’t see a way to report the progress of loading assemblies.
Assemblies do not seem to load linearly in any particular order, because of this I am not sure how to count the remaining number of assemblies to load. I see no obvious way to get which assemblies are currently loading .
If I could get a list of assemblies that have not yet been loaded by the CLR, I could implement a progress bar using either a standard counter along the lines
progress = numberOfLoadedAssemblies / totalNumberOfAssemblies * 100;
Or, implementing logic from Chris Marisik, a great answer to using a weighted average
I cannot execute the trivial " Directory.GetFiles (). Length ". To get the total number of assemblies to download. The reason is that the CLR does not load assemblies in any particular order. It seems to load some assemblies from the application root, then some from the GAC, then more from the application root.
I would like to know if there is a way to get the list of remaining assemblies for download.