Using Sqlite in WinRT App

5 replies. Last post: October 2, 2014 4:37 AM by Yudi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Jan EeckhoutMember

Hi all,

I've recently started a trial of crosslight mobile studio for a proof of concept.

What i'm trying to do is creating a simple Windows 8.1 app with local database access using SQLite. But i'm having some trouble with the SQLite part :)

I have 2 projects, "App.Core" and "App.WinRT". 

In the core project I've made a reference with the following assemblies:

  • .NET
  • Intersoft.AppFramework
  • Intersoft.Crosslight
  • Intersoft.Crosslight.Data
  • Intersoft.Crosslight.Data.ComponentModel
  • Intersoft.Crosslight.Data.SQLite
  • Several Nuget packages to get this project to build (Some Microsoft Bcl packages.
In the WinRT project I've made references to same intersoft assemblies. I also made a reference to the Intersoft.Crosslight.Data.SQLite.WinRT assembly (which is the platform specific assembly) and an SDK extension package called SQLite for Windows Runtime (Windows 8.1)

In the AppService class constructor in the Core project I've added some Appsettings and a SQLiteService.

            AppSettings settings = new AppSettings();

            settings.RequiresInternetConnection = false;
            settings.LocalDatabaseName = "database.db3";
            settings.LocalDatabaseLocation = LocalFolderKind.Data;
            settings.DataSynchronizationMode = DataSynchronizationMode.LoadPartial;

            this.GetService<ITypeResolverService>().Register(typeof(CrosslightAppAppService).Assembly);

            //Container.Current.RegisterInstance(settings);
            Container.Current.Register<IEntityContainer>("Default", c => new EntityContainer()).WithLifetimeManager(new ContainerLifetime());

            ServiceProvider.AddService<ISQLiteService, SQLiteService>();

In the OnStart method i've added the following lines.

            ISQLiteService service = ServiceProvider.GetService<ISQLiteService>();
            ISQLiteAsyncConnection connection = service.OpenConnection("database.db3");

These lines throws the following error: 

System.Exception: The SQLite platform service is not initialized. Please make sure the Intersoft.Crosslight.Data.SQLite.[platform] is referenced in your project.
   at Intersoft.AppFramework.Services.SQLiteService.OpenConnection(String dbName)
   at CrosslightApp2.Infrastructure.CrosslightAppAppService.OnStart(StartParameter parameter)
   at Intersoft.Crosslight.ApplicationServiceBase.Intersoft.Crosslight.IApplicationService.OnStart(StartParameter parameter)
   at Intersoft.Crosslight.WinRT.Application.

I've added a sample solution to this thread. Can someone please tell me what to do in order to create a local SQLite database and access it from the windows RT app.

Thanks!

Kind regards,

Jan

1 attachment
All times are GMT -5. The time now is 1:14 PM.
Previous Next