Composite UI from multiple assemblies

Jan 6, 2011 at 10:29 AM

The application I am working on has a need for a framework like Caliburn.Micro.

It's is likely that in the future, the application will become a lot more modular, and it would be great to see how to load assemblies at runtime containing Caliburn screens etc.

There is a CodeProject article for Caliburn itself - http://www.codeproject.com/KB/WPF/Caliburn_Module_Loading.aspx - is this a reasonable place to start?

Many thanks

Coordinator
Jan 6, 2011 at 1:44 PM

There are two things you need to think about when dynamically loading modules with Caliburn.Micro. The first is that, if you are using an IoC container, your types need to be registered with it when the module is loaded. The second is more CM specific. When CM tries to locate Views, it inspects the types in assemblies registered with AssemblySource.Instance. During startup, when the bootstrapper is run, it calls an override called SelectAssemblies, which can be used to declare statically linked modules to inspect. By default the base implementation of this method only returns the assembly which contains the application. But, you can easily override it and return any assemblies you want. If you are dynamically loading assemblies throughout the coarse of the application's lifetime, you can simply add the assembly instance at any time to the AssemblySource.Instance. It is a simple collection. If you are using MEF, there is some other trickiness involved, I believe. If you search the forums, you should find some sample code for how to do it though. Those are the only requirements to get things working.

Jan 7, 2011 at 2:22 PM

Thanks for the advice - I'll have a go.