2010-12-23 5 views
0

내 ASP.NET MVC2 응용 프로그램이ASP.NEt MVC 2 응용 프로그램 오류가

여기

이 전화 컨트롤러 코드 모델에 대한 SQL로 1. VS 2010 2 Linq를 사용하여 개발되는 로컬 컴퓨터에서 잘 작동합니다 : IIS7에

namespace CallTrackMVC.Controllers 
{ 
    public class CallController : Controller 
    { 
     private CallTrackRepository repository; 

     public CallController():this(new CallTrackRepository()) 
     { 
     } 

     public CallController(CallTrackRepository newRepository) 
     { 
      repository = newRepository; 
     } 
} 
} 

오류 통화가 페이지를 만들고 검색

NullReferenceException: Object reference not set to an instance of an object.] CallTrackMVC.Models.ExecOfficeDataContext..ctor() in C:\ClearCase\rartadi_view\STS_Dev_TEST\CallTrackMVC\Models\ExecOffice.designer.cs:71 CallTrackMVC.Controllers.CallController..ctor() in C:\ClearCase\rartadi_view\STS_Dev_TEST\CallTrackMVC\Controllers\CallController.cs:16 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +117 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +247 System.Activator.CreateInstance(Type type, Boolean nonPublic) +106 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +102 [InvalidOperationException: **An error occurred when trying to create a controller of type 'CallTrackMVC.Controllers.CallController'. Make sure that the controller has a parameterless public constructor.**] System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +541 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +85 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +165 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +80 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +389 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371 

입니다 Global.asax에있는

코드는 어떤 제안이 큰 도움이 될 것

protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 
     RegisterRoutes(RouteTable.Routes); 
    } 

입니다.

+0

당신은 ExecOffice.desginer.cs에서 71 행을 확인해야합니다. 액티베이터가 datatcontex throw 때문에 컨트롤러를 만들 수없는 것처럼 보입니다. 디자이너 코드를 보여주세요. –

답변

-1

인터페이스가없는 경우 "불쌍한 사람의 디"를 사용할 필요가 없습니다.

은 당신의 코드를 보면 다음과 같이합니다

public class CallController : Controller 
    { 
     private readonly CallTrackRepository _repository; 

     public CallController() 
     { 
      _repository= new CallTrackRepository(); 
     } 
} 

이이 문제를 해결해야한다.

관련 문제