I have a situation where I have a Windows Phone Silverlight 8.1 application, and I would like to use a Windows Runtime Component as a background task. In both of these projects, I want to use SQLite for accessing the applications database.
I have found a similar question here:
How to use SQLite in Windows (Phone) 8.1's BackgroundTask
That almost covers the situation, but not quite. Any ideas on how to achieve what I am asking for?
I can get very "close", the latest error message that I am getting during the compilation stage is as follows:
Payload contains two or more files with the same destination path 'sqlite3.pdb'. Source files:
C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\ExtensionSDKs\SQLite.WP80\3.8.11.1\Redist\Debug\ARM\sqlite3.pdb
C:\Program Files (x86)\Microsoft SDKs\WindowsPhoneApp\v8.1\ExtensionSDKs\SQLite.WP81\3.8.11.1\Redist\Debug\ARM\sqlite3.pdb
I am seen the solution to other errors of this type is to simply set the Copy Local to false on one of the references, but I don't see how this would be possible in this case, as both are actually required.
Thanks in advance!
UPDATE 1: Using the suggestion from scottisafool below, I have removed the pdb file from the SQLite SDK folder, and this gets me a little further, i.e. it at least compiles now. However, then I run into another problem...
I then start stubbing out the code for accessing the database in the background task, and after jumping through some hoops with the "not a valid WinRT Type", I am at a point where it all compiles, and looks like it should work. However, when I then try to run the application, and run code that was working fine before, i.e. create the database when the application first loads, I run into this error:
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
with the following stacktrace:
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
at Sqlite.Sqlite3.sqlite3_open_v2(String filename, Database& db, Int32 flags, String zVfs)
at SQLite.Net.Platform.WindowsPhone8.SQLiteApiWP8.Open(Byte[] filename, IDbHandle& db, Int32 flags, IntPtr zVfs)
at SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform, String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks, IBlobSerializer serializer, IDictionary`2 tableMappings, IDictionary`2 extraTypeMappings, IContractResolver resolver)
at SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform, String databasePath, Boolean storeDateTimeAsTicks, IBlobSerializer serializer, IDictionary`2 tableMappings, IDictionary`2 extraTypeMappings, IContractResolver resolver)
at DatabaseContext.OnCreate(String databaseFilePath)
UPDATE 2: The above error message ONLY happens once I add a reference to my Windows Phone 8.1 Portable Class Library (which contains all the SQLite Code) to the BackgroundTask Windows Runtime Component Project. It must be at this point that the:
SDK's are both being pulled into the complete application. At which point, I am assuming that the Windows Phone 8.1 reference is being pulled in, but the Windows Phone reference isn't, because it is seen as already being there. This is complete conjecture, but it would appear to fit with what I am seeing. Any thoughts on how to proceed? Thanks!
I've found the solution:
Add the reference to SQLite dll only in the Silverlight app project and nothing in the background task project (WinRT Runtime Component).
The SQLite.net nuget library will find the dll at runtime, both in app project and in background task project (WinRT Runtime Component).