2011-10-04 3 views
2

현재 프로젝트는 IOC/DI에 mvc-turbines (및 unit)을 사용하여 ASP.NET MVC 1로 작성되었습니다.ASP.NET MVC 1 : MVCTurbines를 사용하여 VS2010으로 이동 한 후 "매개 변수없는 생성자 없음"오류가 발생했습니다.

2008 년부터 응용 프로그램을 시작하려고하면 문제가 없지만 2010 년부터는 "매개 변수없는 생성자"오류가 계속 발생합니다.

왜? 둘 다 동일한 .Net 프레임 워크를 타겟팅합니다. VS 2010 솔루션은 기본 컨트롤러 팩토리를 계속 사용합니다. 이 디버그 제안?

[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 

답변

1

나는 당신 같이 HttpApplication (Global.asax.cs)는 사용자 정의 컨트롤러 공장으로 컨트롤러 공장을 설정하는의 위해 Application_Start() 메소드에있는 것을 가정하고있다.

나는이 코드 줄을 실행하기 전에 예외가 Application_Start()의 어딘가에 던져지고 있다고 생각합니다. 이런 일이 발생하면 이후에 웹 응용 프로그램을 호출 할 때이 예외가 무시되므로 응용 프로그램이 잘못 작동 할 수 있습니다 (예 : 사용자 지정 컨트롤러 팩토리를 사용하지 않는 경우).

Application_Start()를 디버깅하고 올바르게 실행되는지 확인합니다. ELMAH을 사용하는 경우 예외가 기록되어야합니다.

관련 문제