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.

Cannot get Akavache to work using PCL Xamarin Forms app

I've been struggling with this for 4 hours now and I'm now turning in circles. I'm trying to get Akavache to run for my project. The project is a out-of-the-box Xamarin Forms (Portable) type. Then using Nuget I added Akavache 4.1.2 (which also added Akavache Core and SqlLite3 as well as ReactiveUI and Splat). I then updated Splat because the dependency in the nuget package is wrong (was 1.3.3 but should have been 1.6.0). But still I'm getting an error launching this app (targeting iOS for now) when adding the first line that you should have to target this (BlobCache.ApplicationName = "MyApp"):

System.TypeInitializationException: The type initializer for 'Akavache.BlobCache' threw an exception. ---> System.Exception: Failed to initialize Akavache properly. Do you have a reference to Akavache.dll? at Akavache.Sqlite3.Registrations.Register (IMutableDependencyResolver resolver) [0x0001f] in <filename unknown>:0 at Akavache.DependencyResolverMixin.InitializeAkavache (IMutableDependencyResolver This) [0x000c0] in <filename unknown>:0 at Akavache.BlobCache.<.cctor>b__0 () [0x0000d] in <filename unknown>:0 at Splat.Locator.RegisterResolverCallbackChanged (System.Action callback) [0x00039] in <filename unknown>:0 at Akavache.BlobCache..cctor () [0x00018] in <filename unknown>:0

Anyone any ideas?



  • BigmegaBigmega USMember ✭✭

    Are you placing that code in : I have to do on my PCL library class was to open App.cs??? I wrote a blog post about getting this up and running and have helped several people. Take a look and let me know if work

  • PeterDonkerPeterDonker USMember

    @Bigmega Yes, I'm following that pattern.

    **Does anyone know of a (simple) example of a working project on Github? **

    To be clear: Xamarin Forms PCL using Akavache. That way I can see if it runs here on my dev machine and determine if it is a question of referencing or whether something has broken down between Akavache and Xamarin.

  • batmacibatmaci DEMember ✭✭✭✭✭

    @Bigmega what is public override void Initialize() in your app ? there is no such method in PCL project.
    @PeterDonker have you found any good solution for this? I am also struggling with this exception

  • BigmegaBigmega USMember ✭✭
    edited January 2017

    I should be more specific in the blog, will edit so. I'm using MvvmCross and not Xamarin forms that is why I have access to Initialize() method since my App.cs class inherit from "Cirrious.MvvmCross.ViewModels.MvxApplication". It is also a PCL class 4.5 using profile 78. So my class would look like below code

    using Cirrious.CrossCore.IoC;
    using Cirrious.CrossCore;
    using Akavache;
    namespace MyProject
        public class App : Cirrious.MvvmCross.ViewModels.MvxApplication
            public override void Initialize ()
                CreatableTypes ()
                    .EndingWith ("Service")
                    .AsInterfaces ()
                    .RegisterAsLazySingleton ();
                CreatableTypes ()
                    .EndingWith ("Interaction")
                    .AsInterfaces ()
                    .RegisterAsLazySingleton ();
                BlobCache.ApplicationName = "MyApp";
    RegisterAppStart<HomeViewModel> ();

    Will create a xamarin forms project and see if I can get to work then I upload project sample

Sign In or Register to comment.