0

I migrated the opensurce project

http://surveymaster.codeplex.com

from MVC 2 to MVC 4

I have the followinng compiling errors now:

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?)

the error is given on line 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:  <%}%>

There is also source complete compilation souce if you need

Humayun Shabbir
  • 2,961
  • 4
  • 20
  • 33
carni89
  • 1
  • 1
  • 2

3 Answers3

1

Looking at your second image it appears that you are missing some of the classes in Assembly Core.Model. The view you are referring to uses Core.Model.IPageable<Core.Model.SurveySession> but you don't appear to have included SurveySession.cs in Model.Core. Check the source code to ensure all required files and references are included.

Note: Using ASP server controls in MVC 2 was probably considered bad practice back then. Using them in MVC 4 is just awful and I strongly recommend you start from scratch.

  • I searched for only Pagecount elements here https://dl.dropboxusercontent.com/u/17360312/pagecount.png so you cannot see SurveySession.cs. Here https://db.tt/8tdzM99j you can see all the classes of Model.Core – carni89 Aug 07 '14 at 13:06
  • Your error _..'object' does not contain a definition for 'PageCount'.._ is suggesting that the model is not being referenced correctly - in particular note _..are you missing a using directive or an assembly reference?_. I'm afraid that without looking at the whole code and all your references, I can't tell exactly where the problem is. Sorry but I don't have time to do that. –  Aug 07 '14 at 13:30
  • there's no ASP server controls in surveymaster – Omu Aug 07 '14 at 17:53
  • @carni89 if you're using web-forms viewengine and masterpage, you're gonna have asp:Content but there's no usage of controls like asp:Button , label etc. – Omu Aug 08 '14 at 15:35
1

In the Views/Web.config file replace all the occurrences of

System.Web.Mvc, Version=2.0.0.0

with

System.Web.Mvc, Version=4.0.0.0
dmitreyg
  • 2,615
  • 1
  • 19
  • 20
0

The error is coming because there is no property with name PageCount in your model class and there is not any helper or extenstion methods in MVC named PageCount is there, just include PageCount property in your Model class or remove this line from your View and error will be removed.

Thank!!

Kartikeya Khosla
  • 18,743
  • 8
  • 43
  • 69