I have been using the KendoDynamicLinq library for years on this project with no problems. I started to use VS 2017 Community Edition instead of VS 2013 on this same project/code and if I run the project with VS 2017 I get this exception:
System.Reflection.TargetException: 'Non-static method requires a target.'
But if I run it with VS 2013, no problem, no exception and all is working.
I have been wracking my head around this but I cannot seem to find the answer. Any help or direction to point me to would be appreciate it.
private static MethodInfo GetMethod(string methodName, MethodInfo methodTypes, int genericArgumentsCount)
{
var methods = from method in typeof(Queryable).GetMethods(BindingFlags.Public | BindingFlags.Static)
let parameters = method.GetParameters()
let genericArguments = method.GetGenericArguments()
where method.Name == methodName &&
genericArguments.Length == genericArgumentsCount &&
parameters.Select(p => p.ParameterType).SequenceEqual((Type[])methodTypes.Invoke(null, genericArguments))
select method;
return methods.FirstOrDefault();
}
The line that is throwing is this:
parameters.Select(p => p.ParameterType).SequenceEqual((Type[])methodTypes.Invoke(null, genericArguments))
Do you see anything here that can work with VS2013 but not in VS 2017. No changes to the solution or the target framework.