locked
Intellisense not showing AsEnumerable RRS feed

  • Question

  • I had a project originally built in VS 2005 but later upgraded to VS 2008.

    I'm still targeting the .Net 2.0 framework, however, using LinqBridge.  I've got several copies and editions of the project because I've edited it both at home and at the office.

    Right now I've got two Vs 2008 windows open (two editions of the project).  In one of them the "AsEnumerable" method is visible in Intellisense and allows me to write:

    var result = from p in dt.Rows.Cast<DataRow>().AsEnumerable()

    In the other edition, the above line of code won't compile and the "AsEnumerable" method isn't even visible in Intellisense. The compiler message is:

    Error    5    'System.Collections.Generic.IEnumerable<System.Data.DataRow>' does not contain a definition for 'AsEnumerable' and no extension method 'AsEnumerable' accepting a first argument of type 'System.Collections.Generic.IEnumerable<System.Data.DataRow>' could be found (are you missing a using directive or an assembly reference?)   

    The compiler DOES allow me to write this:

    var result = from p in dt.Rows.Cast<DataRow>()

    and I can even do this (with the help of an extension class found on another website)

    DataTable dtResult = result.CopyToDataTable();

    But the problem with  the lack of "AsEnumerable" is that the "var result"  won't bind to a datagridview.  In BOTH projects, I can go to Project > Properties > Application > Target Framework and verify that .Net 2.0 is being targeted.  Does anyone know why Intellisense shows "AsEnumerable" only in one of the two editions?  I thought I might be missing a "using" statement so I copied the "using" list from one edition to the other, but still no joy.
    Saturday, August 28, 2010 9:26 PM

Answers

  • Well, that seems to be the problem. The older version 1.0 features the AsEnumerable but the newer version (1.1) does not.
    • Marked as answer by jal2 Saturday, August 28, 2010 10:27 PM
    Saturday, August 28, 2010 10:12 PM

All replies

  • The only major difference between the two editions, as far as I know, is that one of them started giving me a compiler error: "Missing compiler required member 'System.Runtime.CompilerServices.ExtensionAttribute..ctor'".

     

    To solve this, based on some advice found on the web, I had to do a Project > Add Class and then I pasted the following three lines of code:

        namespace System.Runtime.CompilerServices
        {
            public class ExtensionAttribute : Attribute { }
        }

     I'm now realizing this must be the root of the discrepancy but I'm totally lost as to what to do about it.

     

    Saturday, August 28, 2010 9:40 PM
  • Well, then again, deleting that class did not resolve  the discrepancy (it only resurrected the old compiler error). So I guess that wasn't the problem.
    Saturday, August 28, 2010 9:42 PM
  • Ok, now I'm thinking I've got two different versions of LinqBridge. Oddly, the older version seems to be the one supporting the AsEnumerable.

     

     

    Saturday, August 28, 2010 10:03 PM
  • Well, that seems to be the problem. The older version 1.0 features the AsEnumerable but the newer version (1.1) does not.
    • Marked as answer by jal2 Saturday, August 28, 2010 10:27 PM
    Saturday, August 28, 2010 10:12 PM