Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

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

0.00/5 (No votes)
30 Jul 2014 2  
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
    {}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here