Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Solution won't compile when trying to call Akavache async methods

ScottMacRitchieScottMacRitchie CAMember
edited October 2018 in Xamarin.Forms

Hi all,
I'm creating my first Xamarin app with Xamarin Studio 5.9.3 on a Mac. I created the "Blank Xamarin.Forms App" and chose to the "Use Portable Class Library" option.
All my code is going into the PCL project. I've installed the "Refit" nuget to make async API calls successfully, and the "Xam.Plugin.Connectivity" nuget to determine when I'm online using async methods, so I'm definitely able to use async calls from various other projects.

However, I installed the Akavache plugin and when I try to make calls to its async methods I get "Cannot await..." compiler errors.
For example:

public async Task Test()
{
    return await BlobCache.Secure.Vacuum ();
}

Gives the following error:

Cannot await 'System.IObservable<System.Reactive.Unit>' expression (CS4001)

public async Task<UserModel> Test()
{
    return await BlobCache.Secure.GetObject<UserModel>("test");
}

Gives the following error:

Cannot await 'System.IObservable<OrgAdmin.UserModel>' expression (CS4001)

I've also tried created blank Xamarin.Forms app using the "Shared Library" option and I get the same compiler warnings when I try to make Akavache calls.

My packages.config files looks like this if it helps:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="akavache" version="4.1.1" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="akavache.core" version="4.1.1" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="akavache.sqlite3" version="4.1.1" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="modernhttpclient" version="2.4.2" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Newtonsoft.Json" version="7.0.1" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="refit" version="2.3.0" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Core" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Interfaces" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Linq" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-Main" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Rx-PlatformServices" version="2.2.5" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Splat" version="1.6.2" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="SQLitePCL.raw_basic" version="0.8.0" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Xam.Plugin.Connectivity" version="1.0.2" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
  <package id="Xamarin.Forms" version="1.4.2.6359" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
</packages>

Any idea what I might be doing wrong?

Thanks a lot,
Scott

Tagged:

Best Answer

Answers

  • ScottMacRitchieScottMacRitchie CAMember

    Awesome, thank you @ylemsoul !

Sign In or Register to comment.