Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

//  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.

like image 901
Jim D'Angelo Avatar asked Sep 04 '26 16:09

Jim D'Angelo


1 Answers

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.

like image 122
counsellorben Avatar answered Sep 07 '26 10:09

counsellorben