Skip to content

01 Setup your sync scenario : Server and Client

Alexander Marek edited this page Sep 22, 2017 · 6 revisions

Setup processus

To create a “synchonizable application” that will work on Windows Store apps and Windows Phone 8, you need to create:

  • A web server, which will expose all your entities, and capable of querying and updating a database (SQL SERVER in our example) .Your datas come from a SQL SERVER database, which will be configured to allow synchronization with the Sync Framework
  • A Windows store apps developed in XAML / C#, which will be capable to query your web server and by the way, store all the datas locally in a SQLite database
  • A Windows Phone 8 application developed in XAML / C#, which will be capable to query your web server and by the way, store all the datas locally in a SQLite database

Before starting to develop your projects, be sure to meet those requirements. I know this part is boring, sometimes, but you need to read it carefuly :)

Server

Server

Before starting, you must install on your server, the latest version of Sync Framework 2.1 for .NET:

You have to choose between the x64 version and x86 version : http://www.microsoft.com/en-us/download/details.aspx?id=23217

Visual Studio and Sync Framework

If you install it on a x64 developer machine, you must install both of them, BUT you can’t install both of the x64 and x86 version of the SDK.

The solution is to install :

Once everything installed, you can get the toolkit from Nuget : https://www.nuget.org/packages/SyncClient.SQLite.Service/ Install-Package SyncClient.SQLite.Service

During the preparation of your web server solution, you will have thoses assemblies :

references server

The first three are part of the Sync Framework 2.1

  • Microsoft.Synchronization
  • Microsoft.Synchronization.Data.Server
  • Microsoft.Synchronization.Data.SqlServer

The last one come from the Sync ToolKit nuget Package :

  • Microsoft.Synchronization.Services

Note: I strongly suggest to you to install a local IIS on your development machine. Working with Windows Phone 8 and a locally IIS server is usually more simple and confortable.

IIS

However, if you don’t have a locally IIS web server installed, you have two solutions :

  • Install IIS on your local machine (It’s a good thing, don’t be afraid Sourire)
  • Try to connect your emulator on IIS Express. You can check this todo article : How To Connect a local web service from Windows Phone 8
  • No third option, but you can also … install IIS on your local machine !

Note : As you can imagine, in the followings sections, I will use a local IIS web server.

Windows Store Apps

Regarding the Windows store apps development, the first thing to do is to install SQLite on your machine.

Thanks to Extensions and Update, you just have to search SQLite for Windows Runtime and install it. We will see that you will have to repeat this operation for Windows Phone 8

VS SQLite

You can now add the reference to the toolkit with Nuget :

  • SQLite for Windows Runtime : Obvious
  • Microsoft.Synchronization.ClientServices.Win8 : WinRT Toolkit C# assembly installed by the Nuget package
  • SQLitePCL.pretty - A wrapper to access SQLite from a C# application
  • Microsoft Visual C++ Runtime Package : Required by SQLite

NOTE SQLitePCL.pretty is based on SQLitePCL.raw, the defacto standard low level C# wrapper for SQLite. This library is very flexible when it comes to choosing which version of SQLite you actually want to use. You specify that by installing an additional nuget package. In most of th cases, you will be best advised to go with SQLitePCLRaw.bundle_e_sqlite3.

Run: Install-Package SQLitePCLRaw.bundle_e_sqlite3 -version 1.1.2

Then somewhere at application startup, you need to call the following static method, to wire up that bundle (e.g. in App.xaml.cs): SQLitePCL.Batteries_V2.Init();

For more information, please refer to the official SQLitePCLRaw documentation

Windows Phone 8

As we have seen previously, you have to install SQLite for Windows Phone with Extensions and Updates And once again, install the WinRT Toolkit with the Nuget package :) :

Here we go, you can synchronize your application right now !