I am attempting to use LinqBridge with Compact Framework 2.0 but I get a MethodAccessException when a Linq Where
method is called.
First I tried using the pre-compiled assembly from BitBucket, my own fork with some minor tweeks to compile for CF, and ctacke's fork from his sdf repo on gitHub.
I've been careful about cleaning between builds and cleaning the deployment dir on the device. Also I've been decompiling using DotPeek to confirm that everything in LinqBridge that should be public is showing up as public.
Update 1
Before I was using the following code and it was working fine
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
foreach (TSource source1 in source)
{
if (predicate(source1))
yield return source1;
}
}
Update 2
The following code throws a MethodAccessException when ran using compact framework 2.0 (using both the precompiled dll from raboof and ctacke's fork), but not in Compact Famework 3.5 (using LinqBridge instead of System.Core), or Full Framework 2.0. So I suspect this is a bug in the Compact Framework 2.0 CLR.
using System.Linq;
static class Program
{
private enum Something { a, b, c };
[MTAThread]
static void Main()
{
var dict = new Dictionary<Something, Something>();
dict.Add(Something.a, Something.a);
dict.RemoveByValue(Something.a);
}
}
public static class DictionaryExtentions
{
public static void RemoveByValue<TKey, TValue>(this IDictionary<TKey, TValue> dict, TValue value)
{
foreach (var item in dict.Where(kvp => kvp.Value.Equals(value)).ToArray())
{
dict.Remove(item.Key);
}
}
}