Remove the reference under References.
Go up to your packages folder and search for that assembly in any packages.
Look for any offending wrong version of the assembly. If you locate it, then you can see what nuget package it is being pulled in under. If you find one that is the wrong version, then go in VS and uninstall that nuget package from all projects.
Another troubleshooting step is to open the project file as XML and look for the Reference tag. Usually there is a HintPath such as this that will clue you in to the offending package or hard reference. (By "offending", I mean to allow us to determine where it is finding the assembly that is the wrong incompatible version)
<HintPath>..\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll</HintPath>
This is how you'd find a bad hard coded path as a result of someone using the "Browse" option when adding an assembly, which is a bad practice when dealing with BCL assemblies.
Note I never edit the project file at this point to repoint the reference. This is just to figure out where the offender is at and remove either the package or the bad assembly if another dev has checked in the binary to the solution(another terrible practice for BCL libraries).
Clean+Rebuild and it should be broken because there is no assembly reference.
At this point I've cleaned out the bad reference. It used to be now I would use the Add Reference -> and select from the Framework section. This basically is a GAC reference.
These days I now get the appropriate nuget package, which should add the correct reference based on your target framework, you can explicitely choose the version of the assembly you want, just make sure all related projects in your solution are using the same version to avoid problems:
https://www.nuget.org/packages/System.IO/
This can be difficult to work out because often their is not an official package for your single assembly, but is contained in a larger package named something like Microsoft.BCL or Microsoft.AspNet.WebAPI.Client(Which I have used to get Http assemblies). This is what I find to be the most difficult part, but looks like the above link should give you the specific version you need(hopefully).
Installing the nuget package should add the reference to your project now(this is why we removed any other reference that would prevent the correct one from being added). Double check your Output tab and the various "Show output from:" sections to make sure there were no errors during the nuget install.
These days most of these are pulled in through a nuget package to get the versions in sync across all your related projects. I honestly don't understand why BCL classes are being pulled in through Nuget now when they are part of the installed framework, but this is the way it seems things are done now and the way I get them to consistently work.
System.IO
. You've got a more mundane problem where your build is misconfigured, like referencing assemblies that don't match your platform (which then indirectly referenceSystem.IO
). The .NET Framework assemblies are not the same as the .NET Standard versions of those assemblies; in that sense they are not "equivalent" and you can't mix and match. A .NET Standard project must reference .NET Standard assemblies only. – Jeroen MostertSystem.IO.FileSystem
package, while 4.3.0 is installed. Diagnosing the exact cause from a distance is hard, though. NuGet dependency resolution is notoriously tricky. It will often not automatically "do the right thing" with regards to versions across projects. – Jeroen Mostert