2009-06-09 7 views
1

これは、Microsoft MVC上にある最初のビルドrepoistoryの一部です。MVCモデルの問題でこれが何を言っているのか診断できますか?

コントローラのモデルからの最初の呼び出し。

public ActionResult Index() 
     { 
      var prog = yRepository.FindUpComingProgrammes(); 
      return View(prog); 
     } 

ASPのERROR:

Server Error in '/' Application. 
-------------------------------------------------------------------------------- 

The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[Code.Models.Prog]' but this dictionary requires a model item of type 'Code.Models.Prog'. 
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.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[Code.Models.Prog]' but this dictionary requires a model item of type 'Code.Models.Prog'. 

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: 


[InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery`1[Code.Models.Prog]' but this dictionary requires a model item of type 'Code.Models.Prog'.] 
    System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) +116376 
    System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) +369 
    System.Web.Mvc.ViewPage`1.SetViewData(ViewDataDictionary viewData) +59 
    System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page) +70 
    System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) +92 
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +278 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +10 
    System.Web.Mvc.<>c__DisplayClass11.<InvokeActionResultWithFilters>b__e() +20 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +251 
    System.Web.Mvc.<>c__DisplayClass13.<InvokeActionResultWithFilters>b__10() +19 
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +178 
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399 
    System.Web.Mvc.Controller.ExecuteCore() +126 
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27 
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 
    System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151 
    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 
+0

もう少し詳しい情報が必要だと思っています – ChrisF

答えて

3

あなたは強く型付けされたビューを使用しているように聞こえるし、ビューに渡されるオブジェクトは、ビューがバインドされているタイプが同じではありません...

+0

ありがとうRSolberg - 私の前にちょうどいいです=> –

+0

+1私からコメントを忘れました –

関連する問題