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
{}