There is a old Asp.Net WebSite Project, opened in VS 2015 which targeting a 4.0 FrameWork Version, when I am trying to build it it gives me below error:
The call is ambiguous between the following methods or properties:
System.Linq.Enumerable.Contains<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource)
andSystem.Linq.Enumerable.Contains<TSource>(System.Collections.Generic.IEnumerable<TSource>, TSource)
which both method signature looks exactly identical.
Here it code from the class:
using System;
using System.Collections.Generic; // Gray out
using System.Linq;
using System.Web; // Gray out
using System.Web.Routing;
using System.Web.UI; // Gray out
public class UrlRoute
{
public static string RegisterRoutes(string routes)
{
string MainUrl = routes;
string result = "";
if (MainUrl.Contains('\\')==true)
{
result = "CMS"
}
return result;
}
}
Project Properties:
Framework Details:
I tried solution from SO but none of them worked [delete bin folder, check unresolved references], don't understand the reason behind the error!
EDIT:
Same is happening for Last()
and all that extension method from System.Linq
:
Error CS0121 The call is ambiguous between the following methods or properties: 'System.Linq.Enumerable.Last(System.Collections.Generic.IEnumerable)' and 'System.Linq.Enumerable.Last(System.Collections.Generic.IEnumerable)'
Will love to share any other configuration/code if required.