Assembly uses version X which has a higher version than referenced assembly error

Felix picture Felix · Apr 19, 2018 · Viewed 13.1k times · Source

After upgrading from ASP.NET Core 2.0 to 2.1-preview2 I got the following error:

Error   CS1705  Assembly 'System.Data.SqlClient' with identity 'System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

When I look around for similar errors, I see a lot of discussions about the versions that are referenced in csproj or json files (depending how old the discussion is). But in .NET Core there is only one reference to Microsoft.AspNetCore.App. So, I don't have any way to manipulate the references to either System.Data.SqlClient or System.Runtime

Another observation that while most errors refer to real code like connection.Open() there are two references to non-existent file CSC line 1.

UPDATE: if I create a new project and copy the offending code there, I am not getting any errors. So, apparently the references to the mismatching versions are somewhere in the project... but I can't figure out where!

Answer

Marko picture Marko · Jun 26, 2018

Had the same issue. Resolved by locating RuntimeFrameworkVersion tag in .csproj file and changing it's value to 2.1.