문제

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.

도움이 되었습니까?

해결책

It's may a version of assembly problem

You need to change the assembly to latest version

see this Entry point was not found exception

다른 팁

Fixed my own issue. For some reason, while I created a new MVC5 project, it was still referencing the old WebPages 2.0 and MVC 4 assemblies. No idea why. I ran an update via nuget and it fixed the issues (it also updated other existing MVC4 apps to 5 without issue).

Ramesh, technically your answer is correct.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top