LINQ in VB Issue: Unknown Variable

5 posts, 0 answers
  1. Ken Cox
    Ken Cox avatar
    100 posts
    Member since:
    Oct 2002

    Posted 18 Nov 2009 Link to this post

    I'm looking for a list of known issues but in the meantime, here's one that's causing hundreds of errors in my ASP.NET VB project. I'm using Entity Framework.

    JustCode flags 'apt' in the following as "VisualBasic.NET: Unknown variable or member 'apt'.

            For Each apt In Apts  
                aptinfo = New AppointmentInfo(apt.Subject, apt.Start, apt.End)  
                sessApts.Add(aptinfo)  
            Next 

    Ken
  2. Tsviatko Yovtchev
    Admin
    Tsviatko Yovtchev avatar
    408 posts

    Posted 19 Nov 2009 Link to this post

    Hi Ken

    The known issues list is coming soon, please, stay tuned.

    As for the errors you are experiencing it's kinda hard to reproduce/investigate using the code snippet you provided. Can you provide a self-contained sample, i.e. the complete method where that occurs together with the definitions of all the types used in it where each type refers only primitive types or other types from the sample? If that's not possible what's the closest thing we can get?

    Best wishes,
    Tsviatko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Michael Josiah
    Michael Josiah avatar
    92 posts
    Member since:
    Nov 2007

    Posted 20 Nov 2009 Link to this post

    I am experiancing the same issue. Please try and test the scenario using VB.NET and Linq to Objects. It also does not like inferred variables within a for loop.

    So lets say you have a collection of People objects that you want to loop through

    for each p in persons
      p.name = "michael"
    next

    JustCode would highlight "p" with the message VisualBasic,NET : Unknown member or variable 'p'
  5. Ken Cox
    Ken Cox avatar
    100 posts
    Member since:
    Oct 2002

    Posted 20 Nov 2009 Link to this post

    For an easier example to set up, try the following in an ASP.NET 3.5 VB web page:

        Protected Sub Page_Load _  
          (ByVal sender As Object, ByVal e As System.EventArgs) _  
            Handles Me.Load  
            Dim q = From f In System.Drawing.FontFamily.Families  
            For Each fnt In q  
                Response.Write(fnt.Name & "<br />")  
            Next  
        End Sub 

    You'll see that JustCode flags all the references to "fnt" even though they are valid in VB LINQ.

    Thanks to Michael for also contributing an example.

    Ken
    Microsoft MVP [ASP.NET]
  6. Tsviatko Yovtchev
    Admin
    Tsviatko Yovtchev avatar
    408 posts

    Posted 23 Nov 2009 Link to this post

    Hi guys,

    Thanks a bunch for the code samples. We are able to reproduce the issue on our side now so fixing it is inevitable. We'll let you know as soon as we release the build with that fix. Once again thanks for the code samples. I really appreciate it.


    Best wishes,
    Tsviatko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner