MEF on epi7

Vote:
 

Hello,

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


[ModuleDependency(typeof(InitializationModule))]

class EventsIntegration : IInitializableModule

[ImportingConstructor]
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

#74380
Aug 27, 2013 9:37
Vote:
 

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.

#74395
Aug 27, 2013 11:49
Vote:
 

@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,

#74397
Aug 27, 2013 12:00
Vote:
 

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.

#74412
Aug 27, 2013 14:18
Vote:
 

Hello,

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

#74504
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.