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





0/5 (0 vote)
Solving "The IControllerFactory 'MefContrib.Web.Mvc.CompositionControllerFactory' did not return a controller for the name xxx"
Solution
if you have this
public virtual ViewResult Index(IService service)
{
return View();
}
1) Make sure that the class that implements IService
is decorated with the Export
attribute:
[Export(typeof(IService)), PartCreationPolicy(CreationPolicy.NonShared)]
public class ServiceImplementation : IService
{}
2) Make sure there is no other class exporting the same contract:
[Export(typeof(IService)), PartCreationPolicy(CreationPolicy.NonShared)]
public class AnotherServiceImplementation : IAnotherService
{}