0
votes

Well this one used to work great, before upgrading to .NET 5 from net core 3.1

The extension method that produces the error is

public static IQueryable Set(this myContext context, Type T)
{
    MethodInfo method = typeof(myContext).GetMethod(nameof(myContext.Set), BindingFlags.Public | BindingFlags.Instance);

    method = method.MakeGenericMethod(T);

    return method.Invoke(context, null) as IQueryable;
}

and especially this line

MethodInfo method = typeof(myContext).GetMethod(nameof(myContext.Set), BindingFlags.Public | BindingFlags.Instance);

the stack trace is

   at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at Extensions.QueryableExtensions.Set(RetailContext context, Type T, Boolean dummy) in QueryableExtensions.cs:line 36

Where this Ambiguous error comes from?

Not enough, ahem, context. E.g. what is myContext.Set (how is it declared)? - 500 - Internal Server Error