开发者

MEFContrib.MVC3: Exporting Controllers with Base Classes

I have opened up a question on CodePlex but have not received any responses at all.

Basically, I have a base controller that all of my controllers inherit from. When I create a new MVC3 project, put my controllers in another assembly, and add MEFContrib.MVC3 to the project, everything works great. When I make any of the controllers inherit from my base class, they can no longer be found.

I am not familiar enough with MEFContrib to know what exactly is breaking, but I have tried to decorate my controllers with ExportAttributes and that has not worked, either.

All of this is a different assembly than the main MVC project:

public class MyBaseController : Controller
{
 开发者_如何学JAVA   ...
}

//  This controller cannot be found.
public class HomeController : MyBaseController
{
    public ActionResult Index ()
    {
        // Do Stuff
        return View ();
    }
}

// This controller can be found.
public class HomeController : Controller
{
    // yada, yada, yada...
}

Edit:

counsellorben was exactly right. I had dependencies that were not properly marked for export and so the controllers could not be properly composed. I stepped through each of my dependencies, stepping through their own dependencies, and found the few I missed.


The most likely issue is that there is a problem with a dependency in your MyController class. This will cause a problem with any controller inheriting from MyController.

Please see this answer for some sample code you can use to try and diagnose where your problem lies.


I think you need to decorate with the InheritedExport attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜