Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin: Can not resolve reference: `System.Threading.Tasks.Extensions`, referenced by `MySqlConnector`.

I can't build my Xamarin Android project in Visual Studio 2017.

I keep getting this error:

Can not resolve reference: `System.Threading.Tasks.Extensions`, referenced by `MySqlConnector`. Please add a NuGet package or assembly reference for `System.Threading.Tasks.Extensions`, or remove the reference to `MySqlConnector`.

System.Threading.Tasks.Extensions is installed with NuGet. I need MySqlConnector.

I already cleaned the solution, cleaned all NuGet files, restarted Visual Studio, restarted my PC, reinstalled that NuGet package, reinstalled all NuGet packages, switched from Debug to Release and back, changed C# version, made sure all file permissions were correct on all NuGet files, referenced the System.Threading.Tasks.Extensions as dll, etc.

But the error just stays there. Any ideas what's wrong?

like image 400
Coder14 Avatar asked Oct 10 '18 19:10

Coder14


2 Answers

I believe you are using the System.Threading.Tasks.Extensions in the version of 4.5.1 or 4.5.2, you can try to uninstall the 4.5.1 or 4.5.2 and install version 4.5.0 in your Xamarin. Android project.

As of now (14-Jan-2019), It is a workaround before Xamarin solves the root cause of this issue in the newer version.

like image 200
Jason Avatar answered Nov 15 '22 13:11

Jason


Dec2019 and installing 4.5.0 results in a "java.exe existed with a code 2" failure to build.

Going to try hand editing the android project file as described here: https://forums.xamarin.com/discussion/134422/could-not-load-assembly-system-threading-tasks-extensions

<ItemGroup>
    <PackageReference Include="System.Reactive" Version="4.1.1" />
    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2"/>
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Threading.Tasks.Extensions">
      <HintPath>$(UserProfile)\.nuget\packages\system.threading.tasks.extensions\4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>
  </ItemGroup>
like image 33
Clint StLaurent Avatar answered Nov 15 '22 14:11

Clint StLaurent