0
votes

I am attempting to compile my Xamarin project and I am getting a compiler error that I dont understand. What does the following error mean and how can i fix this?

Data\SQLiteClient.cs(4,4): Error CS0012: The type 'System.Threading.Tasks.TaskScheduler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. (CS0012) (DtoToVm.Droid)

Relevant information:

  • Xamarin Forms blank project PCL
  • Project set to .NET 4.5 or later
  • Profile: PCL 4.5 - Profile78

Alot of references are not happy but I haven't manually setup or editted these. Maybe a nuget package conflict?

enter image description here


using Xamarin.Forms;  
using DtoToVm.Droid.Data;

[assembly: Dependency (typeof(SQLiteClient))]
namespace DtoToVm.Droid.Data  
{
using System;
using DtoToVm.Data;
using SQLite.Net.Async;
using System.IO;
using SQLite.Net.Platform.XamarinAndroid;
using SQLite.Net;

public class SQLiteClient : ISQLite
{
    public SQLiteAsyncConnection GetConnection ()
    {
        var sqliteFilename = "Conferences.db3";
        var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);

        var path = Path.Combine (documentsPath, sqliteFilename);

        var platform = new SQLitePlatformAndroid ();

        var connectionWithLock = new SQLiteConnectionWithLock (
            platform,
            new SQLiteConnectionString (path, true));


        // The below line causes the compile error
        var connection = new SQLiteAsyncConnection (() => connectionWithLock);

        return connection;
    }
}
}

Edit: According to this thread I shd change the profile to 7. I've done this and it got rid of all errors but produced a new one:

DtoToVm\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll: Error CS1703: An assembly with the same identity 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has already been imported. Try removing one of the duplicate references. (CS1703) (DtoToVm)

What file could this duplicate reference be in?

1
Have you tried adding the assembly "System.Threading.Tasks.TaskScheduler" to your project references?helb
Pretty straight forward - it says in the exception - "add a reference to assembly 'System.Threading.Tasks'" to your projectNissim
There is a SQLite PCL NuGet that may save you a lot of trouble - nuget.org/packages/SQLite.Net-PCLJason

1 Answers

0
votes

I don't really know if System.Threading.Tasks namespace exists in Xamarin or not, If it's exists then reference it, If not then use the regular SqliteConnection and don't use Async one.