错误CS1061:'对象'不包含PageCount的定义

时间:2014-08-07 07:41:12

标签: asp.net-mvc migration codeplex

我迁移了opensurce项目

http://surveymaster.codeplex.com

从MVC 2到MVC 4

我现在有以下编译错误:

c:\inetpub\wwwroot\Views\SurveySession\Index.aspx(7,13): error CS1061: 'object' does not contain a definition for 'PageCount' and no extension method 'PageCount' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) 
c:\inetpub\wwwroot\Views\SurveySession\Index.aspx(12,38): error CS1061: 'object' does not contain a definition for 'Page' and no extension method 'Page' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
c:\inetpub\wwwroot\Views\SurveySession\Start.aspx(22,34): error CS1061: 'object' does not contain a definition for 'SurveyId' and no extension method 'SurveyId' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
c:\inetpub\wwwroot\Views\SurveySession\Start.aspx(23,30): error CS1061: 'object' does not contain a definition for 'Questions' and no extension method 'Questions' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
c:\inetpub\wwwroot\Views\SurveySession\Review.aspx(23,34): error CS1061: 'object' does not contain a definition for 'SessionId' and no extension method 'SessionId' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

错误在第7行给出:

Line 5:  </asp:Content>
Line 6:  <asp:Content runat="server" ID="Content1" ContentPlaceHolderID="MainContent">
Line 7:  <% if(Model.PageCount.Equals(0)) {%>
Line 8:  La moment nu sunt chestionare disponibile pentru dvs.
Line 9:  <%}%>

如果需要,还有源完整的编译源

3 个答案:

答案 0 :(得分:1)

查看第二张图片时,您似乎缺少程序集Core.Model中的某些类。您引用的视图使用Core.Model.IPageable<Core.Model.SurveySession>,但您似乎未在SurveySession.cs中添加Model.Core。检查source code以确保包含所有必需的文件和参考。

注意:在MVC 2中使用ASP服务器控件可能被认为是不好的做法。在MVC 4中使用它们非常糟糕,我强烈建议您从头开始。

答案 1 :(得分:1)

在Views / Web.config文件中替换所有出现的

System.Web.Mvc, Version=2.0.0.0

System.Web.Mvc, Version=4.0.0.0

答案 2 :(得分:0)

错误即将发生,因为模型类中没有名称为PageCount的属性,并且在名为extenstion methods的MVC中没有任何帮助器或PageCount,只包括{{在Model类中的1}}属性或从View中删除此行,将删除错误。

感谢!!