tags:

views:

260

answers:

1

My ultimate goal is to load controls as plugins, for use as DocumentContent in AvalonDock. As a result, I will need to be able to create multiple instances of these controls, and I would prefer to do so with as limited overhead for the Plugin creators as possible.

My initial intention was to use MEF to locate and manage my plugins, but this question seems to imply that, at least at this point in time, MEF might not be intended for this.

Should I be using another solution (is the domain of DI containers, or MEF specifically, considered limited to providing instances of classes, and is there another solution that maps better to my problem), or should I use the suggested solutions (such as using reflection to clone instances, or requiring plugin creators to supply factory methods/objects - seemingly hackish) to work with/around MEF (or alternatively, is there a simple way to configure MEF to accomplish this)?

+2  A: 

Hi,

MEF's latest previews includes a type specifically for this scenario - see the blog post here: http://blogs.msdn.com/nblumhardt/archive/2009/08/28/dynamic-part-instantiation-in-mef.aspx or more info on the MEF wiki: http://mef.codeplex.com/Wiki/View.aspx?title=PartCreator&referringTitle=Home.

Cheers, Nick

Nicholas Blumhardt