Every Winform Application MUST have this !

A Splashscreen with current loading Assemblies!!!

Saw this in Citavi - Reference Management and Knowledge Organization 
A Splash form that's shows the loading of the single dlls.

image

 

How to do this?

 

First I saw this Event with Reflector and Intellisense.

 AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(GuiManager.CurrentDomain_AssemblyLoad);

Then I thought that's easy.
But it isn't, cause the main assemblies are already loaded when you put that event registration as first line in your static Main Code.
So they want show up in your output!

 

So the solution is

        [STAThread]
        static void Main()
        {            
            AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
            
            PrintLoadedAssemblies(AppDomain.CurrentDomain);
            // Lists mscorlib and this assembly
   
            Application.Run(new Form());
        }


        private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            Print(args.LoadedAssembly.GetName().Name);
        }

        private static void Print(string name)
        {
            Console.WriteLine(string.Format("Assembly loaded: {0}", name));
            //YourPersonal-SplashScreen.ReportProgress(args.LoadedAssembly.GetName().Name);
        }   

        static void PrintLoadedAssemblies(AppDomain domain)
        {
            foreach (Assembly a in domain.GetAssemblies())
            {
                Print(a.GetName().Name);
            }
        }

 

If you try this in Visual Studio you can see the assemblies listed in the Output Window.
If you try it from the Console you can't see them.

See next post for: How to write to the Console from an Winforms Application

Latest Posts

Popular Posts

 
Google Analytics Alternative