According to the platform specific notes for Akavache:
.NET 4.5 Desktop (WPF) - You must mark your application as x86, or else you will get a strange runtime error about SQLitePCL_Raw not loading correctly.
Right now I'm just trying to test out Akavache in LINQPad using simple code modeled after the sample code on the Akavache Github page.
async void Main()
{
BlobCache.ApplicationName = "JonTestApp1";
var dt = DateTime.Now;
await BlobCache.UserAccount.InsertObject("Test1", dt);
var toaster = await BlobCache.UserAccount.GetObject<DateTime>("Test1");
toaster.Dump();
}
And predictably it is blowing up.
How do I mark my application build target in LINQPad to x86? Using v. 4.53.16, not the AnyCPU build, just the normal beta. I've looked everywhere in the settings and Google but cannot find anything.
Thanks
* Update 1 *
Trying @Joe Albahari 's suggestion. IntPtr.Size
is indeed 4. This is the exception I'm getting on the first await
line:
System.TypeInitializationException: The type initializer for 'NativeMethods' threw an exception. ---> System.Exception: sqlite3.dll was not loaded.
at SQLitePCL.SQLite3Provider.NativeMethods..cctor()
--- End of inner exception stack trace ---
at SQLitePCL.SQLite3Provider.NativeMethods.sqlite3_open_v2(Byte[] filename, IntPtr& db, Int32 flags, Byte[] vfs)
at SQLitePCL.SQLite3Provider.SQLitePCL.ISQLite3Provider.sqlite3_open_v2(String filename, IntPtr& db, Int32 flags, String vfs)
at Akavache.Sqlite3.Internal.SQLiteConnection..ctor(String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks)
at Akavache.Sqlite3.Internal.SQLiteConnection..ctor(String databasePath, Boolean storeDateTimeAsTicks)
at Akavache.Sqlite3.SQLitePersistentBlobCache..ctor(String databaseFile, IScheduler scheduler)
at Akavache.Sqlite3.Registrations.c__DisplayClass6.b__2()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Akavache.Sqlite3.Registrations.c__DisplayClass6.b__3()
at Splat.ModernDependencyResolver.GetService(Type serviceType, String contract) in z:\code\paulcbetts\splat\Splat\ServiceLocation.cs:line 223
at Splat.DependencyResolverMixins.GetService[T](IDependencyResolver This, String contract) in z:\code\paulcbetts\splat\Splat\ServiceLocation.cs:line 138
at Akavache.BlobCache.get_UserAccount()
at UserQuery.d__0.MoveNext() in c:\Users\jcomtois\AppData\Local\Temp\LINQPad\_qizvxzkh\query_rjuuom.cs:line 45
Since I installed Akavache via LINQPad's NuGet, I had to do some searching to find out where sqlite3.dll was. I found about 15 different slqlite3.dll within the Akavache NuGet package (within my AppData/Local/LINQPad/Nuget...) for various builds. I tried copying the one in the x86 folder first to the LINQPad directory, but same error. I then tried copying each of the other of the sqlite3.dll's to the LINQPad folder, but still the same result.
I can't install Visual Studio on this machine so I was hoping there was a way to get this to work with LINQPad.