簡體   English   中英

使用MVC 5和StructureMap“找不到入口點”

[英]“Entry point was not found” with MVC 5 and StructureMap

我正在使用StructureMap 2.6.4.1和一個新的MVC 5項目。 以前,在MVC 4項目中,我們的設置工作正常。

我們有一個SM控制器工廠,例如:

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

Global.asax.cs中 ,在app start中,我們設置如下:

    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

同樣,這在我們的MVC 4項目中運行得很好,但是我找不到與MVC 5有關的足夠信息。我不想恢復到MVC 4,但是如果必須的話。 謝謝。

這可能是裝配問題的一個版本

您需要將程序集更改為最新版本

看到這個入口點未被發現異常

修復了我自己的問題。 出於某種原因,當我創建一個新的MVC5項目時,它仍然引用舊的WebPages 2.0和MVC 4程序集。 不知道為什么。 我通過nuget運行了更新,它修復了問題(它還將其他現有的MVC4應用程序更新為5個沒有問題)。

拉梅什,從技術上講,你的答案是正確的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM