2
votes

I've created a .net core class library which use ADO.net technology .
Used library : System.Data.SqlClient version 4.4.3 from nuget

it works ok in .netcore console application . But, when i use it with Xamarin forms PCL it occurs the following error :

Severity Code Description Project File Line Suppression State Error CS1705 Assembly 'xxx' with identity 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I tried to update System.Runtime library separately but result is the same .
How to fix this problem ?

3

3 Answers

0
votes

The PCL projects rely on a selected API surface (the profile). System.Data.SqlClient however, according to NuGet, does not support any PCL surface but only .NET Standard and various other SDKs. Change your shared library to a .NET Standard one, and the library should work.

0
votes

A couple of options/questions:

  1. Try to consolidate the packages.
  2. Do you get any warnings regarding this?
  3. Check the Xamarin forms PCL libraries that use this package - and match their version. It's highly possible that they don't match versions.
0
votes

This can also happen if a NuGet package acting as a primary reference brings in lower versions of particular assemblies that are required in higher versions by a project referenced.

If you can't fix it with package consolidation, try adding the higher version as a primary reference to the project. Should the error mention a framework assembly, you'd need to add the appropriate metapackage (e.g. Microsoft.AspNetCore.App) to the project as a primary reference.