I'm building a Silverlight 4.0 application with Prism (a.k.a. Composite Application Guidance). I have two modules, both defined in my ModuleCatalog.xaml as WhenAvailable. My Application_OnStart instantiates my Bootstrapper and invokes it's Run() method. Well after my application is started and up and running (in fact, the user has to click a button in the UI), I then attempt to load the modules:
foreach (ModuleInfo mi in moduleCatalog.Modules)
...
Type moduleType = Type.GetType(mi.ModuleType); // moduleType ends up null!
Sometimes, moduleType ends up null. I've verified that when I encounter the null, the ModuleInfo's State is LoadingTypes not ReadyForInitialization. I assume this means it's still downloading the separate *.xap files for my modules and bringing their types into the application domain.
So what can I do? I'd happily block if I knew there was some event I could listen to to know they're finally all loaded.