Click here to Skip to main content
15,888,177 members
Articles / Programming Languages / C#
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
30 Jul 2014CPOL 16.4K   2  
Solving "The IControllerFactory 'MefContrib.Web.Mvc.CompositionControllerFactory' did not return a controller for the name xxx"

Solution

if you have this

C#
public virtual ViewResult Index(IService service)
{
    return View();
}

1) Make sure that the class that implements IService is decorated with the Export attribute:

C#
[Export(typeof(IService)), PartCreationPolicy(CreationPolicy.NonShared)]
    public class ServiceImplementation : IService
    {}

2) Make sure there is no other class exporting the same contract:

C#
[Export(typeof(IService)), PartCreationPolicy(CreationPolicy.NonShared)]
    public class AnotherServiceImplementation : IAnotherService
    {}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Egypt Egypt
Enthusiastic programmer/researcher, passionate to learn new technologies, interested in problem solving, data structures, algorithms, AI, machine learning and nlp.

Amateur guitarist/ keyboardist, squash player.

Comments and Discussions

 
-- There are no messages in this forum --