我有一个asp.net mvc 1.0项目。我将项目和解决方案升级到Visual Studio 2010.但是,我不想使用asp.net mvc 2.0。我的应用程序在mvc 1.0下编译。我所有的参考都是1.0。我复制本地为true,我从lib文件夹引用mvc 1.0,而不是GAC。
但是我一直收到这个错误:
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[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(Type controllerType) +82
[InvalidOperationException: An error occurred while creating a controller of type 'PartingOut.Web.Controllers.HomeController'. If the controller doesn't have a controller factory, ensure that it has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(Type controllerType) +189
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +128
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
它想继续使用asp.net mvc 2.0,因为它抱怨GetControllerInstance方法。
这个项目在vs 2008中运作良好。哇! :(
任何?任何人吗?
提前致谢。
答案 0 :(得分:1)
我只想覆盖所有基础,请原谅我,如果这是一个明显的答案,但是:PartingOut.Web.Controllers.HomeController
实际上是否有一个无参数构造函数?
答案 1 :(得分:1)
我明白了。
与asp.net mvc 2或者vs 2010没什么关系。它还在引用asp.net mvc 1.0。其中一位开发人员完成了升级,并在方法中取出了“覆盖”关键字:
IController GetControllerInstance(Type controllerType)
在我们自己的自定义ControllerFactory上。
咩。