> Hi All,
You have posted to 5 different newsgroups. Don't you think that
.languages.csharp would have sufficed?
> I get an InvalidProgramException
I have adapted your source code to be a complete, compiling sample. It
does not generate an InvalidProgramException. Can you create a complete,
compiling sample which produces the error?
---8<---
using System;
using System.IO;
using System.Query;
using System.Collections.Generic;
public class App
{
public static IEnumerable<DirectoryInfo>
SubDirectories(DirectoryInfo di)
{
yield return di;
foreach (DirectoryInfo directory in di.GetDirectories())
foreach (DirectoryInfo subDirectory in
SubDirectories(directory))
yield return subDirectory;
}
public static IEnumerable<FileInfo> AllFilesUnder(DirectoryInfo d)
{
foreach (DirectoryInfo dir in SubDirectories(d))
foreach (FileInfo fileInfo in dir.GetFiles())
yield return fileInfo;
}
public static IEnumerable<FileInfo>
MatchingFilesUnder(Func<FileInfo,bool> x, DirectoryInfo d)
{
foreach (FileInfo fileInfo in AllFilesUnder(d))
if (x(fileInfo))
yield return fileInfo;
}
public static IEnumerable<FileInfo> FilesByExtension(string ext,
DirectoryInfo d)
{
Func<FileInfo, bool> test = x=>x.Extension==ext;
return Match(test, AllFilesUnder(d));
}
public static IEnumerable<IT> Match<IT>(Func<IT, bool> test,
IEnumerable<IT> col)
{
foreach (IT it in col)
if(test(it))
yield return (it);
}
static void Main()
{
string testdir = @"C:\Program Files";
List<FileInfo> files =
new List<FileInfo>(FilesByExtension(".txt",
new DirectoryInfo(testdir)));
Console.WriteLine(files.Count);
}
}
--->8---
> I am running C# 3.0 May CTP (LINQ preview) and ReSharper 2.0 (2005)
I am running C# 8.00.50916 on 2.0.50727.
-- Barry

Signature
http://barrkel.blogspot.com/
Andrew Matthews - 16 Jul 2006 06:29 GMT
Hello Barry,
Considering that I wasn't sure whether the problem was with C# specifically
or with the CLR I thought I wouldn't take any chances of getting a response.
As for compiling code that gives the error - that was what I posted.
Andrew
>> Hi All,
>>
[quoted text clipped - 63 lines]
>>
> I am running C# 8.00.50916 on 2.0.50727.
Barry Kelly - 16 Jul 2006 06:35 GMT
> As for compiling code that gives the error - that was what I posted.
The code you posted doesn't have a Main method - how can it compile and
produce the error? Did you try the code I posted? How is it different
from your code? Does the code I post show the error on your machine?
A complete sample is described here:
http://www.yoda.arachsys.com/csharp/complete.html
-- Barry

Signature
http://barrkel.blogspot.com/
Andrew Matthews - 16 Jul 2006 06:57 GMT
Hello Barry,
I was using NUnit - I didn't need a main method.
My reason for posting the question was to try to find out what it was about
my code that caused the invalid IL.
Andrew
>> As for compiling code that gives the error - that was what I posted.
>>
[quoted text clipped - 6 lines]
>
> http://www.yoda.arachsys.com/csharp/complete.html
Barry Kelly - 16 Jul 2006 07:41 GMT
> I was using NUnit - I didn't need a main method.
You didn't need a main method, but what about the people you're asking
for help? Do you expect everybody to infer that you are using NUnit,
psychically figure out your version, download it, install it, and modify
your code to execute under NUnit (your code uses namespaces etc.), add
NUnit to the project references, and execute it under NUnit?
Or do you expect them to do what I did - i.e. convert the code into a
complete compiling sample - only to find that it does not perform as you
advertised: it does not cause invalid IL?
I would love help you find a bug is C# 3.0 May release. The trouble is,
you haven't given enough information.
> My reason for posting the question was to try to find out what it was about
> my code that caused the invalid IL.
The code you provided, to the best of my knowledge, does *not* cause
invalid IL. You'll have to produce a complete, compiling sample if you
are to have any hope of anyone helping you with your problem.
-- Barry

Signature
http://barrkel.blogspot.com/
Nicholas Paldino [.NET/C# MVP] - 16 Jul 2006 23:47 GMT
Andrew,
LINQ doesn't require a change to the CLR to work. It is most likely an
issue with the compiler (which is to be expected, as this is a CTP, not even
a beta).
Post a complete example (meaning, no nunit, etc, etc) and we can try it
out, and then if it is an error with the compiler, you can post it to the
product feedback center.
Hope this helps.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hello Barry,
>
[quoted text clipped - 72 lines]
>>>
>> I am running C# 8.00.50916 on 2.0.50727.