Try our conversational search powered by Generative AI!

MEF on epi7



I am learning epi 7, and have some example code. I have an initializable module to register events:


class EventsIntegration : IInitializableModule

public EventsIntegration ([ImportMany] IPageAction[] eventActions)

The IPageAction interface have [InheritedExport] attribute on it.


The problem is when I'm running on the old site using epi 6, everything just works fine. But when I migrate this code to epi7, it throws exception: Constructor of type 'xxxx' not found. Removing the attribute for mef, it works again but using the default constructor.

So any advice that I'm missing configurations or stuff like that?

Best regards,

Dan Le

Aug 27, 2013 9:37

Not sure if I looked at right place, but at sourc code I can find that v7 does not create initializable module instances via MEF anymore. It uses just Activator.CreateInstance. By passing null as second argument - .Net class loader will look for default parameterless constructor.

Aug 27, 2013 11:49

@Valdis Iljuconoks: thanks for the reply, but hmm not sure how to quote in the forum.

From the exception trace I also see Activator trying to create instance. So how should I implement a similar feature to MEF :)


Best regards,

Aug 27, 2013 12:00

You want to "import" (or resolve dependencies) something into a module itself? You could try to get it from ServiceLocator. That guy should be initialized already.

Aug 27, 2013 14:18


Sorry for the late reply, as I was using autofac, I changed the way my module initialize and inject the properties later, so it's working now


Thanks for the help :)
Dan Le

Aug 30, 2013 4:56
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.