I am having that error on this method.
public static FReturn<T> GetByParameters<T>(FObjectParametersb parameters, bool useOr = false) where T : new();
public class FObjectParameters : ICollection<FObjectParameter>, IEnumerable<FObjectParameter>, IEnumerable
{
//some code
}
var parameters = new FObjectParameters();
foreach (KeyValuePair<string, string> item in Param)
parameters.Add(item.Key, item.Value);
var getMethod = MainType.BaseType.BaseType.GetMethod("GetByParameters").MakeGenericMethod(MainType);
object Invoke = getMethod.Invoke(null, new object[] { parameters });
It seems you need to supply the optional parameter
object Invoke = getMethod.Invoke(null, new object[] { parameters, false });
I guess it is because you are calling the method directly with Reflection, so there is no compiler magic.I suppose when you use optional parameters if you don't supply an optional argument compiler calls the method by passing the default value.So in this case you need to provide it, even though its optional...