MefContrib.MVC3 and Lazy<T> imports on controllers

Oct 25, 2011 at 5:04 PM

It took me a while to figure out, but it seems that I cannot have controllers with Lazy imports. To verify, I created a clean test project with MVC3, and used the Nuget packages for MefContrib and MefContrib.MVC3 (version 1.2). I added an import on the HomeController and it worked. Then I wrapped it in Lazy<T> and it only throws the error:

The IControllerFactory 'MefContrib.Web.Mvc.CompositionControllerFactory' did not return a controller for the name 'Home'. 


Interestingly though, I can import objects that contain lazy imports, I just can't have a lazy import directly on the controller itself. Am I missing something here?

Oct 26, 2011 at 6:20 AM

Those are indeed not supported at the moment.

Nov 29, 2011 at 1:40 AM

I am getting a similar error on all my controllers after updating to version 1.2. However I am not using Lazy<T> at all. I never have. Is there something else that can cause this? Or better yet, where do I start to try and debug this issue?

Feb 16, 2012 at 6:08 AM

I get same error too. Can everybody help please???

Feb 16, 2012 at 7:21 AM

Can you post a small repro project so I can investigate?