"Entry point was not found" with MVC 5 and StructureMap

Viewed 6511

I'm using StructureMap 2.6.4.1 with a new MVC 5 project. Previously, in MVC 4 projects, our setup works fine.

We have a SM controller factory, such as this:

public class StructureMapControllerFactory : DefaultControllerFactory
    {
        protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            var instance = ObjectFactory.GetInstance(controllerType) as IController;

            if (instance == null)
            {
                return base.GetControllerInstance(requestContext, controllerType);
            }

            return instance;
        }
    }

And in the Global.asax.cs, in app start, we set it like this:

    ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory());

The issue is, if this last line is enabled in app start, we get this:

**[EntryPointNotFoundException: Entry point was not found.]**
   System.Web.Mvc.IControllerFactory.GetControllerSessionBehavior(RequestContext requestContext, String controllerName) +0
   System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(RequestContext requestContext) +131
   System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +33
   System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +10
   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9767524
   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Again, this works just fine in our MVC 4 projects, but I cannot find enough information that relates to MVC 5. I'd hate to revert back to MVC 4, but will if I have to. Thanks.

2 Answers
Related