7
votes

I am getting version conflict error when using System.Data.SqlClient.dll in .Net Core 2.0. Its look like conflict between Core dll and NetStandard dll. Not sure why referring

"System.Data.SqlClient, Version=4.5.0.0

which was not existing.

Web application call Business library and in turn business library call DAL. DAL is using System.Data.SqlClient.dll. All are in .Net Core2.0.

Can you please help?

Here is the error.

1> There was a conflict between "System.Data.SqlClient, Version=4.2.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 1> "System.Data.SqlClient, Version=4.2.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. 1> References which depend on "System.Data.SqlClient, Version=4.2.0.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.data.sqlclient\4.4.3\ref\netstandard2.0\System.Data.SqlClient.dll]. 1> C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.data.sqlclient\4.4.3\ref\netstandard2.0\System.Data.SqlClient.dll 1> Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.data.sqlclient\4.4.3\ref\netstandard2.0\System.Data.SqlClient.dll". 1> C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.data.sqlclient\4.4.3\ref\netstandard2.0\System.Data.SqlClient.dll 1> References which depend on "System.Data.SqlClient, Version=4.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. 1> D:\Projects.Net Core\Test Apps\Postsharp\SmartBank.Web\SmartBank.Core.Business\SmartBank.Core.Business\bin\Debug\netcoreapp2.0\SmartBank.Core.DAL.dll 1> Project file item includes which caused reference "D:\Projects.Net Core\Test Apps\Postsharp\SmartBank.Web\SmartBank.Core.Business\SmartBank.Core.Business\bin\Debug\netcoreapp2.0\SmartBank.Core.DAL.dll". 1> SmartBank.Core.Business 1> C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2052,5): warning MSB3277: Found conflicts between different versions of "System.Data.SqlClient" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

1

1 Answers

-1
votes

I had the same problem: ORM library using System.Data.SqlClient.dll (version 4.6.0) directly but Microsoft.AspNetCore.App transitively imports it as well with version 4.5.1.

I've switched the ORM library to using the same version as the one in Microsoft.AspNetCore.App but I'm a bit worried what happens when I upgrade