NLOG, Log to SQLite on windows Phone 8
I have a Windows Phone application in wich I want to add NLog. The data from Nlog I want to put in a SQLite database.
If I'm doing this in a WindowsForm Application it is no problem, I just add NLog and System.Data.SQLite form the Nuget. But what to to on Windows phone 8?
I have installed Nlog all ready. (Downloaded it and add the reference manually) but how do I add System.Data.SQLite to the project? When I try installing it from Nuget I get the following error:
"Could not install package 'System.Data.SQLite.Core.MSIL 184.108.40.206'. You are trying to install this package into a project that targets 'WindowsPhone,Version=v8.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
I just recently wrote an article about how to use SQLite in Windows Phone 8 (mainly 8.1) but it should be the same. You can find this article here: http://www.brainchest.net/?p=1401
In short, what you have to do is the following:
- Download the SQLite for Windows Phone 8.1 extension by going to Tools –> Extensions and Updates –> Search for “SQLite for Windows Phone 8.1″ online and add a reference to your project (I guess you'd need "SQLite for Windows Phone" instead if you are targeting Windows Phone 8.0 and above).
- Via NuGet download the following packages into your project: SQLite.Net PCL, SQLite.Async.Net PCL, sqlite-net-wp8, SQLite.Net PCL - WindowsPhone8 Platform
- Set the platform target to either x86 or ARM, depending on where you deploy your project. For the emulator use x86, for the device use ARM. AnyCPU doesn't work because SQLite itself is native.