GetEnumerator not found on foreach in MVC app.

Posts   
 
    
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 03-Sep-2010 21:08:53   

It turns out I had not resolved myearlier problem. I am using MVC and am getting this error, this used to work last year, and I've checked all my reference versions since I've moved to LLBL V3.

Error 1 foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator' c:\Projects\glossary-mvc\Index.aspx

for reference the index.aspx line in question is this

    <% foreach (var item in Model) { %>

and I have done a google on this and I have the MVC ASPX page set up correctly as follows:

<%@ Page Title="" 
    Language="C#" 
    MasterPageFile="~/Views/Shared/Site.Master" 
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<glossaryDB.EntityClasses.AssociationTypeEntity>>"
%>

So I went looking for the GetEnumerator for my EntityClass and I can't see one, was this removed in V3 or moved?

Suggestions ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 06-Sep-2010 04:25:07   

I can't reproduce your problem. I successfully made a Northwind MVC app using LLBLGen v3. Please generate the code again, this time in an empty folder and try again. I suspect there is something wrong in your old folders (maybe old files or something like that).

If you can't resolve it, please post more information that help us to reproduce the problem. Maybe a tiny repro application that reproduces the problem would be helpful.

David Elizondo | LLBLGen Support Team
quentinjs avatar
quentinjs
User
Posts: 110
Joined: 09-Oct-2009
# Posted on: 07-Sep-2010 19:34:01   

Problem solved!

For reference: I moved to .Net 4, LLBLGen 3 and MVC 3 so I had many moving parts.

I replaced the entire web.config in the Views section with one from a "new" MVC3 application, and the problem went away.