Code calling a method that is ambiguous with itself?

I have a line of code like this:

var results = new GroupedCountsModel { XAxis = entities.ListGroupKeys(fieldNameX) };

When I try to compile this code, I get a build error:

The call is ambiguous between the following methods or properties: 
'MyProject.Shared.QueryGeneration.GroupByHelper.ListGroupKeys<TEntity>(System.Linq.IQueryable<TEntity>, string)' 
and 
'MyProject.Shared.QueryGeneration.GroupByHelper.ListGroupKeys<TEntity>(System.Linq.IQueryable<TEntity>, string)'    
C:\{mypath}\MyProject.Shared\Controllers\BaseEntityController.cs

This is interesting because the two methods listed in the error are exactly the same. This is not like I have the same method signature defined in a different namespace or assembly. I don’t know why the compiler thinks they are different when the compiler itself points to the same method twice. Here is the method:

public static class GroupByHelper
{
    public static List<object> ListGroupKeys<TEntity>(this IQueryable<TEntity> source, string fieldName)
        where TEntity : class, IDataEntity
    {
        //...etc...
    }
    //...etc..
}

What could be the reason for this? How can I fix this problem?

+3
source share
1 answer

So it was weird. I'm not sure how this happened.

. , , , MyProject.Shared. - MyProject.Shared . , , :-) , , , , , . , , , . .

MyProject.Shared MyProject.Shared, .

Thanks to those who suggested checking the reference assemblies and their versions. It made me notice self-esteem.

0
source

All Articles