我正在使用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,中,我们将其设置为:
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,但如果有必要的话,我会这样做。谢谢。
发布于 2013-12-13 18:23:50
发布于 2013-12-16 14:36:57
解决了我自己的问题。由于某些原因,当我创建一个新的MVC5项目时,它仍然引用旧的WebPages 2.0和MVC 4程序集。不知道为什么。我通过nuget运行了一个更新程序,它修复了这些问题(它还更新了其他现有的MVC4应用程序,使其没有问题)。
拉梅什严格来说你的答案是正确的。
https://stackoverflow.com/questions/20573309
复制相似问题