Search code examples
linqreferenceorchardcmsmethod-invocationambiguous-call

Ambiguous invocation caused by picking up two versions of System.Linq


I have the following code, which shows a squiggly red line under the lambda expression after .Any( because of an "ambiguous invocation" between System.Linq versions 3.5 and 4.0 - how do I force it to use a particular version?

It compiles and runs fine.

string[] allowedExtensions = { "PNG", "JPG", "JPEG", "GIF" };
string fileExtension = (Path.GetExtension(postedFile.FileName) ?? "NULL").ToUpper().TrimStart(new[] { '.' });

if (this.MediaService.FileAllowed(postedFile) 
    && allowedExtensions.Any(e => e == fileExtension))
{ ... }

UPDATE:

I've now checked all (60) projects in the entire solution and all the references to System.dll and System.Core.dll are version 4.0 - I really can't understand where it's getting the reference to 3.5 from.


Solution

  • You probably have two modules that reference different versions. Search the project files for those references and bring them to consistency (4.0).