c# – 使用MVC 5和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,但是如果必须的话.谢谢.
解决方法:
这可能是装配问题的一个版本
您需要将程序集更改为最新版本
看这Entry point was not found exception
标签:c,asp-net,asp-net-mvc,asp-net-mvc-5,structuremap 来源: https://codeday.me/bug/20190629/1324014.html