Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 已将项目升级到Visual Studio 2010,但现在出现MVC错误_Asp.net_Asp.net Mvc - Fatal编程技术网

Asp.net 已将项目升级到Visual Studio 2010,但现在出现MVC错误

Asp.net 已将项目升级到Visual Studio 2010,但现在出现MVC错误,asp.net,asp.net-mvc,Asp.net,Asp.net Mvc,我有一个asp.NETMVC1.0项目。我将项目和解决方案升级到VisualStudio2010。但是,我不想使用asp.net mvc 2.0。我的应用程序在MVC1.0下编译。我所有的参考文献都是1.0。我有copy local true,我是从lib文件夹引用mvc 1.0,而不是GAC 然而,我不断地得到这个错误: No parameterless constructor defined for this object. Description: An unhandled except

我有一个asp.NETMVC1.0项目。我将项目和解决方案升级到VisualStudio2010。但是,我不想使用asp.net mvc 2.0。我的应用程序在MVC1.0下编译。我所有的参考文献都是1.0。我有copy local 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.NETMVC2.0,因为它抱怨GetControllerInstance方法

该项目在vs 2008中运行良好。哇(

有人吗?有人吗


提前谢谢。

我只是想介绍一下这里的所有基础,如果这是一个显而易见的答案,请原谅我,但是:
PartingOut.Web.Controllers.HomeController
真的有一个无参数构造函数吗?

我想出来了

与asp.net mvc 2或vs 2010无关。它仍然引用asp.net mvc 1.0。其他一名开发人员已完成升级,并删除了方法中的“overrides”关键字:

IController GetControllerInstance(类型controllerType)

在我们自己的定制控制器工厂


Meh.

您的
HomeController
是如何定义的?不,它没有。但它不应该。我正在将StructureMap与DI一起使用,因此它具有注入到其中的依赖项。HomeController应该始终通过构造函数将其依赖项传递给它。错误消息显示
System.Web.Mvc.DefaultControllerFactory
Iit’他试图实例化你的控制器,而不是StructureMap。我以前没有在MVC中使用StructureMap,但它不应该是实例化控制器的那个吗?是的,我想不出来。我有一个自定义的ControllerFactory,它使用结构图,我在global.asax.cs中设置了结构图,并且它正在运行那行代码。但是我仍然设置引用defaultcontrollerfactory的错误。