I\'m porting a Net Framework 4 dll to Net Core. When porting my unit tests project I get an exception running some specific tests (not all).
System.IO
I had this problem, while I had 10 projects depending on each other. I fixed that by adding the version that it asked for in one of the projects that was dependent on. It was not needed for compilation, but it seems that adding it, fixed the version in other projects while restoring. So it was:
Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Then:
Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
So I added "System.Net.Http": "4.1.1", in one project..
That actually fixed the problem while it restored 8 projects.
Fixed it by updating System.Net.Http to 4.3.1
My problem was that my service had a referenced assembly that had a reference to a newer version of System.Net.Http. I've resolved the issue by updating System.Net.Http in the service.
I tried out various solutions (removing the dependentAssembly OR specifying the binding redirect as well). None of them worked.
However, the only solution which worked for me was to explicitly set Specific Version for System.Net.Http (or whatever DLL giving you version issues) to False from Visual Studio.
I got the issue, and realized that it was because I had two different references. one reference was from my project library, and the second one was a dependency of a .Net Standard library, and therefore a Nuget package. The steps to solve were the following:
System.Net.Http
(project => add reference => remove the reference).Update-Package –reinstall System.Net.Http
to bring back the reference.Now it works again. :)
The best and easiest way to fix this issue, is with a binding redirect.
Simply specify the oldVersion as 0.0.0.0-5.0.0.0, and newVersion as 4.1.1.0
Where 4.1.1.0 is you version, for example.