Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly System.Data.SqlClient, Version=4.2.0.2 when I use System.Data.SqlClient Version 4.4.3

I use System.Data.SqlClient Version 4.4.3 for all .NET Standard 2.0 class libraries in my ASP.NET Core 2.0 project. Why do I get

Could not load file or assembly 'System.Data.SqlClient, Version=4.2.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

when the project is published with VSTS to Azure App Service? And of course it perfectly works on my machine!

All this worked yesterday. But today I decided to update packages to:

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" /> 
like image 639
alvipeo Avatar asked Mar 22 '18 21:03

alvipeo


People also ask

Can not load file or assembly?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.

Where is Microsoft Data SqlClient?

The Microsoft. Data. SqlClient API details can be found in the . NET API Browser.

What is System data SqlClient?

Represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database. This class cannot be inherited.


2 Answers

Don't know whether this is the same situation that I faced. I added System.Data.SqlClient via nuGet and it worked fine.

like image 172
Watz Avatar answered Sep 22 '22 12:09

Watz


Downgraded to

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" /> 

and everything works again! Lost 4 hours today!!!

like image 31
alvipeo Avatar answered Sep 23 '22 12:09

alvipeo