0

I am in the process of writing a WPF application that hosts 10+ usercontrols I have written. What I would like to do is modify the code from "Wonko the Sane"'s answer in this post

Is there a way to show a splash screen for WPF application?

to dynamically show the name of these usercontrol dll's as they load.

I have not been able to find anywhere how to get the names of dll's as they load.

Any assistance would be appreciated.

Thanks, Jim

Community
  • 1
  • 1
Jim
  • 201
  • 2
  • 12

2 Answers2

1

Sorry, but you won't be able to do that. The WPF Framework loads before your program starts executing. The best that you'll be able to do is to add the names of the relevant DLLs into a string collection and then loop through them, displaying each one temporarily. Even if you could display what was being loaded, the chances are that they'd actually load so quick that you wouldn't see anything anyway.

It's also worth pointing out that it is only really worth having a splash screen in a WPF Application if you have a real lot of initialisation loading to do. In that case, you can show what the application is doing, but you'll probably find that in most cases, the loading is still done too fast for the UI to update in time.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
  • As it is taking 5+ seconds to load it all up some indication even if it isn't names would be useful. Most of the controls have an OnLoaded event and set up public parameters for the other controls to use so thats whats taking a bit time up. – Jim Mar 18 '14 at 22:14
  • I don't know about that control that you're using, but you might have to use asynchronous calls in order to get the text to update in the splash screen while you are loading whatever in background tasks... maybe something like this: `splashScreen.Dispatcher.BeginInvoke((Action)(() => splashScreen.Status = "Loading something..."));` – Sheridan Mar 18 '14 at 23:05
1

You can get the current application domain and then use AssemblyLoad event to get loaded Dll name.

AppDomain MyDomain = AppDomain.CurrentDomain;
MyDomain.AssemblyLoad += new AssemblyLoadEventHandler(SplashControllerObject.LocalEventHandler);


private void LocalEventHandler(object sender, AssemblyLoadEventArgs args)
{
//use sender.LoadedAssembly.FullName   for DLL name loaded
}
gvisgr8
  • 31
  • 1
  • I will give that a try and let you know how it goes. As I mentioned it is taking some time as I now have 15+ of my dll's to load. – Jim May 07 '15 at 06:12
  • I tried this but it didn't work var _myDomain = AppDomain.CurrentDomain; _myDomain.AssemblyLoad += new AssemblyLoadEventHandler(MyAssemblyLoadEventHandler); static void MyAssemblyLoadEventHandler(object sender, AssemblyLoadEventArgs args) { Debug.WriteLine("ASSEMBLY LOADED: " + args.LoadedAssembly.FullName); Debug.WriteLine(Environment.NewLine); } – Jim May 14 '15 at 22:12