Caliburn Micro: plugin-related questions for MEF-based scenario?

If so, you can use the CompositionHost to manually initialise the container used to satisfy imports, e.g. : var catalog = new AggregateCatalog( new DirectoryCatalog("bin"), new DirectoryCatalog("Plugins")); CompositionHost. Initialise(catalog) Any calls to CompositionInitialiser. SatisfyImports(...) will use a container constructed from the catalogs you created If you are looking to be able to create instances of exports programmatically, you will need reference to the actual CompositionContainer itself.

But to do this, we need another alternative way of initialising composition. You could create a container and hold a reference to it, e.g. : var catalog = new AggregateCatalog( new DirectoryCatalog("bin"), new DirectoryCatalog("Plugins")); var container = new CompositionContainer(catalog); CompositionHost. Initialise(container); Container = container where Container is a static reference to your CompositionContainer instance.

We've changed the call to CompositionHost to specificy the exact container that CompositionInitializer will use, so that all still works correctly, but we then have a container that we can use to create specific instances, e.g. : var viewModel = Container.GetExport() Does that help?

If so, you can use the CompositionHost to manually initialise the container used to satisfy imports, e.g. : var catalog = new AggregateCatalog( new DirectoryCatalog("bin"), new DirectoryCatalog("Plugins")); CompositionHost. Initialise(catalog); Any calls to CompositionInitialiser. SatisfyImports(...) will use a container constructed from the catalogs you created.

If you are looking to be able to create instances of exports programmatically, you will need reference to the actual CompositionContainer itself. But to do this, we need another alternative way of initialising composition. You could create a container and hold a reference to it, e.g. : var catalog = new AggregateCatalog( new DirectoryCatalog("bin"), new DirectoryCatalog("Plugins")); var container = new CompositionContainer(catalog); CompositionHost.

Initialise(container); Container = container; ...where Container is a static reference to your CompositionContainer instance. We've changed the call to CompositionHost to specificy the exact container that CompositionInitializer will use, so that all still works correctly, but we then have a container that we can use to create specific instances, e.g. : var viewModel = Container.GetExport(); Does that help?

Thank you, this might be a good hint, but sadly the application I'm working on at the moment is a WPF application, and CompositionHost is not available. The typical MEF bootstrapper sampled for CM uses a CompositionHost for SL and a code like this for WPF: _container = new CompositionContainer( new AggregateCatalog(AssemblySource.Instance. Select (x => new AssemblyCatalog(x)).OfType())); – Naftis Jun 5 at 14:04 Can you update your code to present how you are constructing your container and how it wires into CM?

– Matthew Abbott Jun 5 at 17:31 The final part of my edited post probably does the trick. Anyway, I'm still facing some issues with CM and MEF, some on the MEF part, so this is an argument for another post...:) When I get a clearer insight I'll try to update this post too. – Naftis Jun 8 at 20:18 For anyone who might be interested, I updated my question in the first post.It seems the problem lies in the fact that CM cannot locate the view when it's hosted into another assembly, even if the viewmodel lies in the same assembly, they follow the naming conventions and they are both Exported with MEF.

– Naftis Jun 10 at 17:58 If you search the discussion forums I've seen threads talking about this and how to fix it. – Derek Beattie Jun 13 at 17:44.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions