Today I’m going to explain to all of you how I managed to pass the Windows Store Certification using Sqlite and MvvmCross.

During my first attempts I received several errors when trying to pass the certification kit and, even once I managed to pass the kit, then the Store rejected my packages stating that there was some errors in my referenced dlls.

If you find yourself fighting the same battle, let’s try this. Here I will expose my final setup and what I did to finally publish my app in the Windows Store supporting x86, x64 and ARM. Hopefully, it will work for you, too.

I must say I’m using the Community SQLite plugin not the old one and I install it via Nuget. This way all platform dlls will be downloaded to your packages folder. By default, x86 dll is referenced so if you try to build your project for x64 or ARM it won’t work. Later we will discuss how I handle this issue.

The second thing you have to take into account is that you need a reference to sqlite3.dll for the project to run. The easiest way to make this work is to install a vsix package from SQLite.org download’s page. Go there, look for the Precompiled Binaries for Windows Runtime section and choose your preferred vsix package version (depending on your visual studio version).

Once installed, add a reference to your project and select Windows > Extensions on the right column. Here you have to select SQLite for Windows Runtime and, this is very important, add a reference to Microsoft Visual C++ Runtime package for Windows. If you don’t do this last step, you won’t be able to pass the Store certification so I can’t  stress this point enough: remember to add a reference to Microsoft Visual C++ Runtime for Windows!!

Adding Sqlite reference

If you have done all this then you’re about to accomplish your goal. Now it comes the trickiest part…

If you remember, we said that sqlite plugin uses x86 dll as the default reference. You maybe expect that, as this plugin was installed as a nuget package, it will keep the reference according to the selected build platform on your configuration manager but, unfortunately, it won’t.

If you try to build your project for x64 you will receive an error similar to this one: “There was a mismatch between the processor architecture of the project being built […] and the processor architecture of the reference […]“.

Mismatch sqlite error

Don’t worry, we’re going to use Conditional Constructs in our .csproj file in order to change the path of the reference depending on the platform we’re willing to build for. The hint came from  Stuart Lodge so all the credit is his 😀

Let’s see how we can do it:

  1.  Go to your project in the Solution Explorer, right click and select “Edit Project File.
  2. Locate in the file the reference to Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore and delete it.
         <Reference Include="Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore, Version=1.0.0.0, Culture=neutral, processorArchitecture=ARM">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>..\packages\MvvmCross.Community.Plugin.Sqlite.3.1.1\lib\netcore45\x86\Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore.dll</HintPath>
        </Reference>
    
  3. Paste this piece of code just before one of your ItemGroup sections:
      <Choose>
        <When Condition="'$(Platform)' == 'x64'">     
          <ItemGroup> 
            <Reference Include="Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore, Version=1.0.0.0, Culture=neutral, processorArchitecture=ARM">
              <SpecificVersion>False</SpecificVersion>
              <HintPath>..\packages\MvvmCross.Community.Plugin.Sqlite.3.1.1\lib\netcore45\x64\Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore.dll</HintPath>
            </Reference>
          </ItemGroup>     
        </When>
        <When Condition="'$(Platform)' == 'ARM'">
          <ItemGroup>
            <Reference Include="Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore, Version=1.0.0.0, Culture=neutral, processorArchitecture=ARM">
              <SpecificVersion>False</SpecificVersion>
              <HintPath>..\packages\MvvmCross.Community.Plugin.Sqlite.3.1.1\lib\netcore45\ARM\Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore.dll</HintPath>
            </Reference>
          </ItemGroup>
        </When>
        <Otherwise>
            <ItemGroup>
              <Reference Include="Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore, Version=1.0.0.0, Culture=neutral, processorArchitecture=ARM">
                <SpecificVersion>False</SpecificVersion>
                <HintPath>..\packages\MvvmCross.Community.Plugin.Sqlite.3.1.1\lib\netcore45\x86\Cirrious.MvvmCross.Community.Plugins.Sqlite.WindowsStore.dll</HintPath>
              </Reference>
            </ItemGroup>
        </Otherwise>
      </Choose>
    
    
  4. Now you can reload your project and check that everything compiles just as expected even changing your platform selection.
  5. Finally, you can create your app packages and pass the Windows Store certification process 😀

I hope this works fine for you. Let me know if you find some issues while facing this solution and I will try to help you. 😀