ASP.NET MVC 1:“;“无参数构造函数”-移动到VS2010后出错(使用MVCTURBINE)
我们当前的项目是用ASP.NET MVC 1编写的,它使用用于IOC/DI的MVC turbines(和unity) 当我尝试从2008年开始启动应用程序时,一切正常,但从2010年开始,我一直得到“无参数构造函数”错误 为什么?? 两者的目标都是相同的.Net框架。VS 2010解决方案继续使用默认控制器工厂。对调试这个有什么建议吗ASP.NET MVC 1:“;“无参数构造函数”-移动到VS2010后出错(使用MVCTURBINE),.net,asp.net-mvc,turbine,.net,Asp.net Mvc,Turbine,我们当前的项目是用ASP.NET MVC 1编写的,它使用用于IOC/DI的MVC turbines(和unity) 当我尝试从2008年开始启动应用程序时,一切正常,但从2010年开始,我一直得到“无参数构造函数”错误 为什么?? 两者的目标都是相同的.Net框架。VS 2010解决方案继续使用默认控制器工厂。对调试这个有什么建议吗 [MissingMethodException: No parameterless constructor defined for this object.]
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
[InvalidOperationException: An error occurred when trying to create a controller of type 'CommonProject.Web.Shared.Controllers.MyController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +190
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +68
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +118
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +46
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler, HttpContextBase httpContext) +61
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext) +111
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext) +40
System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +7
CommonProject.Web._Default.Page_Load(Object sender, EventArgs e) in
我假设在HttpApplication(Global.asax.cs)的Application_Start()方法中,您将控制器工厂设置为自定义控制器工厂 我相信在执行这行代码之前,会在应用程序_Start()中的某个地方抛出异常。如果发生这种情况,对web应用程序的任何后续调用都将绕过此异常,这可能导致应用程序行为异常(例如不使用自定义控制器工厂) 我将调试应用程序_Start(),并确保它正确执行。如果正在使用,则应记录异常