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.
I had this problem after ReSharper offered to 'reference System.Core' and 'import System.Linq' in a file where I was using a Linq expression but hadn't yet imported 'System.Linq'. When I executed the ReSharper command, I got some error that part of it had failed. Then all Linq expressions in my project were ambiguous between System.Core 3.5 and 4.0. Looking at all my System and System.Core references, they were 4.0. Removing the reference to System.Core (4.0) caused the ambiguity errors to go away, and made System.Core disappear from the list of references for that project. When I went back to re-add System.Core, although it did not appear in my list of references in Solution Explorer, it was checked in the 'Add Reference to ' dialog. Attempting to un-check it there and then re-check it resulted in an error that System.Core is already referenced by my project. I'm still fixing errors so I don't know if this will affect the build process.