Felix
Felix

Reputation: 10078

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

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!

Upvotes: 20

Views: 23240

Answers (2)

David Castro
David Castro

Reputation: 1957

Using Visual Studio, the easiest way is:

1.- Right-click on the solution and go to "Manager Nugget Packages for solution..."

2.- Go to "Consolidate tab" (The last on the right side) You will see the different versions of assemblies on each project.

  • Try to unify the version for all project references within your solution. (Uninstall and install the same version).

Good Luck!!

Upvotes: 2

Marko
Marko

Reputation: 1592

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

Upvotes: 8

Related Questions