-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Compile problems with Visual Studio 2005
PostPosted: Thu Aug 18, 2005 2:34 pm 
I am unable to compile the following code from Quick Start using Visual Studio 2005:

Code:
1   IList userList = session.CreateCriteria(typeof(User)).List();
2   foreach (User currentUser in userList)
3   {
4       System.Diagnostics.Debug.WriteLine(
5           currentUser.Id + " last logged in at " + currentUser.LastLogon);
6   }


The errors I get are:

Line 1: Using the generic type 'System.Collections.Generic.IList<T>' requires '1' type arguments
Line 2: foreach statement cannot operate on variables of type '?IList?' because '?IList?' does not contain a public definition for 'GetEnumerator'

Even if try typecasting I get an InvalidCastException at runtime:

Code:
IList<User> userList = (IList<User>)(session.CreateCriteria(typeof(User)).List());


Is there a solution to this?


Top
  
 
 Post subject: Just a guess
PostPosted: Thu Aug 18, 2005 5:11 pm 
Newbie

Joined: Mon Aug 08, 2005 11:09 am
Posts: 4
I saw something like this in my coding. The default template for new classes will include
Code:
using System.Collections.Generic;


However, IList is in System.Collections. I think the compiler is trying to resolve your IList reference in line 1 and getting IList<T> instead. If you add
Code:
using System.Collections;

to your usings, I think you'll be alright.


Jay


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 6:33 pm 
Yes, that was it! Thanks so much for hlping me out on this.


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.