21 March 2009 0 Comments

Why doesn’t MEF support open-generics for exports? Because MEF is not type based.

I get this question all the time. Recently it popped it’s head on the forums in this thread (which I referred to in my last post ) In that thread, Andrew was asking why the following does not work? [Export( typeof (IDomainController<>)), CompositionOptions(CreationPolicy = CreationPolicy.Shared)] public class DomainController<T> : IDomainController<T> { /* some code here */ [ImportingConstructor] public DomainController(IRepository repository) {   _Repository = repository } } That is he wants to export a generic IDomainController with the idea the closed generic versions like IDomainController<Customer> could be imported

View original here: 
Why doesn’t MEF support open-generics for exports? Because MEF is not type based.

If you liked this post, buy me a Coffee.

Leave a Reply